Skip to content

Commit 3e7bef7

Browse files
Add total active power sensor to Tesla Wall Connector integration. (home-assistant#151028)
Co-authored-by: Erik Montnemery <[email protected]>
1 parent 1222828 commit 3e7bef7

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

homeassistant/components/tesla_wall_connector/sensor.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
UnitOfElectricPotential,
1717
UnitOfEnergy,
1818
UnitOfFrequency,
19+
UnitOfPower,
1920
UnitOfTemperature,
2021
)
2122
from homeassistant.core import HomeAssistant
@@ -164,6 +165,15 @@ class WallConnectorSensorDescription(
164165
state_class=SensorStateClass.MEASUREMENT,
165166
entity_category=EntityCategory.DIAGNOSTIC,
166167
),
168+
WallConnectorSensorDescription(
169+
key="total_power_w",
170+
translation_key="total_power_w",
171+
native_unit_of_measurement=UnitOfPower.WATT,
172+
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
173+
value_fn=lambda data: data[WALLCONNECTOR_DATA_VITALS].total_power_w,
174+
device_class=SensorDeviceClass.POWER,
175+
state_class=SensorStateClass.MEASUREMENT,
176+
),
167177
WallConnectorSensorDescription(
168178
key="session_energy_wh",
169179
translation_key="session_energy_wh",

homeassistant/components/tesla_wall_connector/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"status_code": {
7676
"name": "Status code"
7777
},
78+
"total_power_w": {
79+
"name": "Total power"
80+
},
7881
"voltage_a_v": {
7982
"name": "Phase A voltage"
8083
},

tests/components/tesla_wall_connector/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def get_vitals_mock() -> Vitals:
101101
mock.currentA_a = 10
102102
mock.currentB_a = 11.1
103103
mock.currentC_a = 12
104+
mock.total_power_w = 7650.3
104105
mock.session_energy_wh = 1234.56
105106
mock.contactor_closed = False
106107
mock.vehicle_connected = True

tests/components/tesla_wall_connector/test_sensor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ async def test_sensors(hass: HomeAssistant) -> None:
5353
EntityAndExpectedValues(
5454
"sensor.tesla_wall_connector_phase_c_voltage", "232.1", "230"
5555
),
56+
EntityAndExpectedValues(
57+
"sensor.tesla_wall_connector_total_power", "7.6503", "5.4995"
58+
),
5659
EntityAndExpectedValues(
5760
"sensor.tesla_wall_connector_session_energy", "1.23456", "0.1122"
5861
),
@@ -73,6 +76,7 @@ async def test_sensors(hass: HomeAssistant) -> None:
7376
mock_vitals_second_update.currentA_a = 7
7477
mock_vitals_second_update.currentB_a = 8
7578
mock_vitals_second_update.currentC_a = 9
79+
mock_vitals_second_update.total_power_w = 5499.5
7680
mock_vitals_second_update.session_energy_wh = 112.2
7781

7882
lifetime_mock_first_update = get_lifetime_mock()

0 commit comments

Comments
 (0)