From 60c06732b1e72311bae4150b2a5fb18a817478fe Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 5 Jun 2024 16:06:23 +0200 Subject: [PATCH] Add state and device class to incomfort (#118877) * Add state and device class to incomfort * Add state and device class to incomfort --- .../components/incomfort/binary_sensor.py | 2 ++ homeassistant/components/incomfort/sensor.py | 4 ++++ .../incomfort/snapshots/test_binary_sensor.ambr | 3 ++- .../incomfort/snapshots/test_sensor.ambr | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/incomfort/binary_sensor.py b/homeassistant/components/incomfort/binary_sensor.py index e3563c183daab..580001238bd12 100644 --- a/homeassistant/components/incomfort/binary_sensor.py +++ b/homeassistant/components/incomfort/binary_sensor.py @@ -9,6 +9,7 @@ from incomfortclient import Heater as InComfortHeater from homeassistant.components.binary_sensor import ( + BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) @@ -32,6 +33,7 @@ class IncomfortBinarySensorEntityDescription(BinarySensorEntityDescription): IncomfortBinarySensorEntityDescription( key="failed", name="Fault", + device_class=BinarySensorDeviceClass.PROBLEM, value_key="is_failed", extra_state_attributes_fn=lambda status: {"fault_code": status["fault_code"]}, ), diff --git a/homeassistant/components/incomfort/sensor.py b/homeassistant/components/incomfort/sensor.py index 4bba56382b36f..191d3715122c4 100644 --- a/homeassistant/components/incomfort/sensor.py +++ b/homeassistant/components/incomfort/sensor.py @@ -11,6 +11,7 @@ SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.const import UnitOfPressure, UnitOfTemperature from homeassistant.core import HomeAssistant @@ -42,6 +43,7 @@ class IncomfortSensorEntityDescription(SensorEntityDescription): key="cv_pressure", name=INCOMFORT_PRESSURE, device_class=SensorDeviceClass.PRESSURE, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=UnitOfPressure.BAR, value_key="pressure", ), @@ -49,6 +51,7 @@ class IncomfortSensorEntityDescription(SensorEntityDescription): key="cv_temp", name=INCOMFORT_HEATER_TEMP, device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=UnitOfTemperature.CELSIUS, extra_key="is_pumping", value_key="heater_temp", @@ -57,6 +60,7 @@ class IncomfortSensorEntityDescription(SensorEntityDescription): key="tap_temp", name=INCOMFORT_TAP_TEMP, device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=UnitOfTemperature.CELSIUS, extra_key="is_tapping", value_key="tap_temp", diff --git a/tests/components/incomfort/snapshots/test_binary_sensor.ambr b/tests/components/incomfort/snapshots/test_binary_sensor.ambr index 0316f37502d90..e783245997481 100644 --- a/tests/components/incomfort/snapshots/test_binary_sensor.ambr +++ b/tests/components/incomfort/snapshots/test_binary_sensor.ambr @@ -21,7 +21,7 @@ 'name': None, 'options': dict({ }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Fault', 'platform': 'incomfort', @@ -35,6 +35,7 @@ # name: test_setup_platform[binary_sensor.boiler_fault-state] StateSnapshot({ 'attributes': ReadOnlyDict({ + 'device_class': 'problem', 'fault_code': None, 'friendly_name': 'Boiler Fault', }), diff --git a/tests/components/incomfort/snapshots/test_sensor.ambr b/tests/components/incomfort/snapshots/test_sensor.ambr index 831be411b46e2..3998141c306d1 100644 --- a/tests/components/incomfort/snapshots/test_sensor.ambr +++ b/tests/components/incomfort/snapshots/test_sensor.ambr @@ -4,7 +4,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -37,6 +39,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'pressure', 'friendly_name': 'Boiler CV Pressure', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -52,7 +55,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -86,6 +91,7 @@ 'device_class': 'temperature', 'friendly_name': 'Boiler CV Temp', 'is_pumping': False, + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -101,7 +107,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -135,6 +143,7 @@ 'device_class': 'temperature', 'friendly_name': 'Boiler Tap Temp', 'is_tapping': False, + 'state_class': , 'unit_of_measurement': , }), 'context': ,