File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed
homeassistant/components/tesla_wall_connector
tests/components/tesla_wall_connector Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1616 UnitOfElectricPotential ,
1717 UnitOfEnergy ,
1818 UnitOfFrequency ,
19+ UnitOfPower ,
1920 UnitOfTemperature ,
2021)
2122from 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" ,
Original file line number Diff line number Diff line change 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 },
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ()
You can’t perform that action at this time.
0 commit comments