mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Add total active power sensor to Tesla Wall Connector integration. (#151028)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
@@ -16,6 +16,7 @@ from homeassistant.const import (
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -164,6 +165,15 @@ WALL_CONNECTOR_SENSORS = [
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
WallConnectorSensorDescription(
|
||||
key="total_power_w",
|
||||
translation_key="total_power_w",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
value_fn=lambda data: data[WALLCONNECTOR_DATA_VITALS].total_power_w,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
WallConnectorSensorDescription(
|
||||
key="session_energy_wh",
|
||||
translation_key="session_energy_wh",
|
||||
|
||||
@@ -75,6 +75,9 @@
|
||||
"status_code": {
|
||||
"name": "Status code"
|
||||
},
|
||||
"total_power_w": {
|
||||
"name": "Total power"
|
||||
},
|
||||
"voltage_a_v": {
|
||||
"name": "Phase A voltage"
|
||||
},
|
||||
|
||||
@@ -101,6 +101,7 @@ def get_vitals_mock() -> Vitals:
|
||||
mock.currentA_a = 10
|
||||
mock.currentB_a = 11.1
|
||||
mock.currentC_a = 12
|
||||
mock.total_power_w = 7650.3
|
||||
mock.session_energy_wh = 1234.56
|
||||
mock.contactor_closed = False
|
||||
mock.vehicle_connected = True
|
||||
|
||||
@@ -53,6 +53,9 @@ async def test_sensors(hass: HomeAssistant) -> None:
|
||||
EntityAndExpectedValues(
|
||||
"sensor.tesla_wall_connector_phase_c_voltage", "232.1", "230"
|
||||
),
|
||||
EntityAndExpectedValues(
|
||||
"sensor.tesla_wall_connector_total_power", "7.6503", "5.4995"
|
||||
),
|
||||
EntityAndExpectedValues(
|
||||
"sensor.tesla_wall_connector_session_energy", "1.23456", "0.1122"
|
||||
),
|
||||
@@ -73,6 +76,7 @@ async def test_sensors(hass: HomeAssistant) -> None:
|
||||
mock_vitals_second_update.currentA_a = 7
|
||||
mock_vitals_second_update.currentB_a = 8
|
||||
mock_vitals_second_update.currentC_a = 9
|
||||
mock_vitals_second_update.total_power_w = 5499.5
|
||||
mock_vitals_second_update.session_energy_wh = 112.2
|
||||
|
||||
lifetime_mock_first_update = get_lifetime_mock()
|
||||
|
||||
Reference in New Issue
Block a user