Skip to content

Commit

Permalink
Add missing Weheat temperature sensors (#128452)
Browse files Browse the repository at this point in the history
Co-authored-by: Joost Lekkerkerker <[email protected]>
  • Loading branch information
barryvdh and joostlek authored Oct 16, 2024
1 parent 144454b commit dddc190
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 25 deletions.
14 changes: 4 additions & 10 deletions homeassistant/components/weheat/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,17 @@
"cop": {
"default": "mdi:speedometer"
},
"water_inlet_temperature": {
"default": "mdi:thermometer"
},
"water_outlet_temperature": {
"default": "mdi:thermometer"
},
"ch_inlet_temperature": {
"default": "mdi:radiator"
},
"outside_temperature": {
"default": "mdi:home-thermometer-outline"
},
"dhw_top_temperature": {
"default": "mdi:thermometer"
"thermostat_room_temperature": {
"default": "mdi:home-thermometer"
},
"dhw_bottom_temperature": {
"default": "mdi:thermometer"
"thermostat_room_temperature_setpoint": {
"default": "mdi:home-thermometer"
},
"heat_pump_state": {
"default": "mdi:state-machine"
Expand Down
27 changes: 27 additions & 0 deletions homeassistant/components/weheat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ class WeHeatSensorEntityDescription(SensorEntityDescription):
suggested_display_precision=DISPLAY_PRECISION_WATER_TEMP,
value_fn=lambda status: status.air_inlet_temperature,
),
WeHeatSensorEntityDescription(
translation_key="thermostat_water_setpoint",
key="thermostat_water_setpoint",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=DISPLAY_PRECISION_WATER_TEMP,
value_fn=lambda status: status.thermostat_water_setpoint,
),
WeHeatSensorEntityDescription(
translation_key="thermostat_room_temperature",
key="thermostat_room_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=DISPLAY_PRECISION_WATER_TEMP,
value_fn=lambda status: status.thermostat_room_temperature,
),
WeHeatSensorEntityDescription(
translation_key="thermostat_room_temperature_setpoint",
key="thermostat_room_temperature_setpoint",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=DISPLAY_PRECISION_WATER_TEMP,
value_fn=lambda status: status.thermostat_room_temperature_setpoint,
),
WeHeatSensorEntityDescription(
translation_key="heat_pump_state",
key="heat_pump_state",
Expand Down
9 changes: 9 additions & 0 deletions homeassistant/components/weheat/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
"outside_temperature": {
"name": "Outside temperature"
},
"thermostat_water_setpoint": {
"name": "Water target temperature"
},
"thermostat_room_temperature": {
"name": "Current room temperature"
},
"thermostat_room_temperature_setpoint": {
"name": "Room temperature setpoint"
},
"dhw_top_temperature": {
"name": "DHW top temperature"
},
Expand Down
3 changes: 3 additions & 0 deletions tests/components/weheat/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def mock_weheat_heat_pump_instance() -> MagicMock:
mock_heat_pump_instance.power_output = 66
mock_heat_pump_instance.dhw_top_temperature = 77
mock_heat_pump_instance.dhw_bottom_temperature = 88
mock_heat_pump_instance.thermostat_water_setpoint = 35
mock_heat_pump_instance.thermostat_room_temperature = 19
mock_heat_pump_instance.thermostat_room_temperature_setpoint = 21
mock_heat_pump_instance.cop = 4.5
mock_heat_pump_instance.heat_pump_state = HeatPump.State.HEATING
mock_heat_pump_instance.energy_total = 12345
Expand Down
136 changes: 122 additions & 14 deletions tests/components/weheat/snapshots/test_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,60 @@
'state': '4.5',
})
# ---
# name: test_all_entities[sensor.test_model_current_room_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.test_model_current_room_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Current room temperature',
'platform': 'weheat',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'thermostat_room_temperature',
'unique_id': '0000-1111-2222-3333_thermostat_room_temperature',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_all_entities[sensor.test_model_current_room_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'Test Model Current room temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.test_model_current_room_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '19',
})
# ---
# name: test_all_entities[sensor.test_model_dhw_bottom_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
Expand Down Expand Up @@ -496,7 +550,7 @@
'state': '44',
})
# ---
# name: test_all_entities[sensor.test_model_power_output-entry]
# name: test_all_entities[sensor.test_model_room_temperature_setpoint-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
Expand All @@ -510,7 +564,7 @@
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.test_model_power_output',
'entity_id': 'sensor.test_model_room_temperature_setpoint',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
Expand All @@ -520,34 +574,34 @@
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 0,
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.POWER: 'power'>,
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'power output',
'original_name': 'Room temperature setpoint',
'platform': 'weheat',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'power_output',
'unique_id': '0000-1111-2222-3333_power_output',
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
'translation_key': 'thermostat_room_temperature_setpoint',
'unique_id': '0000-1111-2222-3333_thermostat_room_temperature_setpoint',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_all_entities[sensor.test_model_power_output-state]
# name: test_all_entities[sensor.test_model_room_temperature_setpoint-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'power',
'friendly_name': 'Test Model power output',
'device_class': 'temperature',
'friendly_name': 'Test Model Room temperature setpoint',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.test_model_power_output',
'entity_id': 'sensor.test_model_room_temperature_setpoint',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '77',
'state': '21',
})
# ---
# name: test_all_entities[sensor.test_model_water_inlet_temperature-entry]
Expand Down Expand Up @@ -658,3 +712,57 @@
'state': '22',
})
# ---
# name: test_all_entities[sensor.test_model_water_target_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.test_model_water_target_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Water target temperature',
'platform': 'weheat',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'thermostat_water_setpoint',
'unique_id': '0000-1111-2222-3333_thermostat_water_setpoint',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_all_entities[sensor.test_model_water_target_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'Test Model Water target temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.test_model_water_target_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '35',
})
# ---
2 changes: 1 addition & 1 deletion tests/components/weheat/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def test_all_entities(
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)


@pytest.mark.parametrize(("has_dhw", "nr_of_entities"), [(False, 9), (True, 11)])
@pytest.mark.parametrize(("has_dhw", "nr_of_entities"), [(False, 12), (True, 14)])
async def test_create_entities(
hass: HomeAssistant,
mock_weheat_discover: AsyncMock,
Expand Down

0 comments on commit dddc190

Please sign in to comment.