Tesla wall connector add sensors (#117769)

pull/117841/head
Bernardus Jansen 2024-05-21 09:30:24 +02:00 committed by GitHub
parent 0fb78b3ab3
commit d0b1ac6918
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 0 deletions

View File

@ -77,6 +77,24 @@ WALL_CONNECTOR_SENSORS = [
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
),
WallConnectorSensorDescription(
key="pcba_temp_c",
translation_key="pcba_temp_c",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value_fn=lambda data: round(data[WALLCONNECTOR_DATA_VITALS].pcba_temp_c, 1),
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
),
WallConnectorSensorDescription(
key="mcu_temp_c",
translation_key="mcu_temp_c",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value_fn=lambda data: round(data[WALLCONNECTOR_DATA_VITALS].mcu_temp_c, 1),
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
),
WallConnectorSensorDescription(
key="grid_v",
translation_key="grid_v",

View File

@ -51,6 +51,12 @@
"handle_temp_c": {
"name": "Handle temperature"
},
"pcba_temp_c": {
"name": "PCB temperature"
},
"mcu_temp_c": {
"name": "MCU temperature"
},
"grid_v": {
"name": "Grid voltage"
},

View File

@ -20,6 +20,12 @@ async def test_sensors(hass: HomeAssistant) -> None:
EntityAndExpectedValues(
"sensor.tesla_wall_connector_handle_temperature", "25.5", "-1.4"
),
EntityAndExpectedValues(
"sensor.tesla_wall_connector_pcb_temperature", "30.5", "-1.2"
),
EntityAndExpectedValues(
"sensor.tesla_wall_connector_mcu_temperature", "42.0", "-1"
),
EntityAndExpectedValues(
"sensor.tesla_wall_connector_grid_voltage", "230.2", "229.2"
),
@ -55,6 +61,8 @@ async def test_sensors(hass: HomeAssistant) -> None:
mock_vitals_first_update = get_vitals_mock()
mock_vitals_first_update.evse_state = 1
mock_vitals_first_update.handle_temp_c = 25.51
mock_vitals_first_update.pcba_temp_c = 30.5
mock_vitals_first_update.mcu_temp_c = 42.0
mock_vitals_first_update.grid_v = 230.15
mock_vitals_first_update.grid_hz = 50.021
mock_vitals_first_update.voltageA_v = 230.1
@ -68,6 +76,8 @@ async def test_sensors(hass: HomeAssistant) -> None:
mock_vitals_second_update = get_vitals_mock()
mock_vitals_second_update.evse_state = 3
mock_vitals_second_update.handle_temp_c = -1.42
mock_vitals_second_update.pcba_temp_c = -1.2
mock_vitals_second_update.mcu_temp_c = -1
mock_vitals_second_update.grid_v = 229.21
mock_vitals_second_update.grid_hz = 49.981
mock_vitals_second_update.voltageA_v = 228.1