diff --git a/custom_components/aguaiot/const.py b/custom_components/aguaiot/const.py index 343b5fb..623f685 100644 --- a/custom_components/aguaiot/const.py +++ b/custom_components/aguaiot/const.py @@ -264,7 +264,7 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:fire", native_unit_of_measurement=None, state_class=None, - device_class=None, + device_class=SensorDeviceClass.ENUM, ), AguaIOTSensorEntityDescription( key="alarms_get", @@ -272,7 +272,7 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:alert-outline", native_unit_of_measurement=None, state_class=None, - device_class=None, + device_class=SensorDeviceClass.ENUM, force_enabled=True, ), AguaIOTSensorEntityDescription( @@ -281,8 +281,8 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:gauge", native_unit_of_measurement=None, state_class=None, - device_class=None, force_enabled=True, + device_class=SensorDeviceClass.ENUM, ), AguaIOTSensorEntityDescription( key="real_power_wood_get", @@ -290,8 +290,8 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:gauge", native_unit_of_measurement=None, state_class=None, - device_class=None, force_enabled=True, + device_class=SensorDeviceClass.ENUM, hybrid_only=True, ), AguaIOTSensorEntityDescription( @@ -300,7 +300,7 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:fan", native_unit_of_measurement=None, state_class=None, - device_class=None, + device_class=SensorDeviceClass.ENUM, ), AguaIOTSensorEntityDescription( key="vent_rear2_get", @@ -308,7 +308,7 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:fan", native_unit_of_measurement=None, state_class=None, - device_class=None, + device_class=SensorDeviceClass.ENUM, ), AguaIOTSensorEntityDescription( key="type_combustible_get", @@ -316,7 +316,7 @@ class AguaIOTCanalizationEntityDescription(ClimateEntityDescription): icon="mdi:gas-burner", native_unit_of_measurement=None, state_class=None, - device_class=None, + device_class=SensorDeviceClass.ENUM, ), AguaIOTSensorEntityDescription( key="pres_h2o_get", diff --git a/custom_components/aguaiot/sensor.py b/custom_components/aguaiot/sensor.py index 42f86ac..cbed77b 100644 --- a/custom_components/aguaiot/sensor.py +++ b/custom_components/aguaiot/sensor.py @@ -4,7 +4,7 @@ CoordinatorEntity, DataUpdateCoordinator, ) -from homeassistant.components.sensor import SensorEntity +from homeassistant.components.sensor import SensorEntity, SensorDeviceClass from homeassistant.helpers.entity import DeviceInfo from .const import SENSORS, DOMAIN @@ -69,5 +69,25 @@ def extra_state_attributes(self): return { "raw_value": self._device.get_register_value( self.entity_description.key - ) + ), } + + @property + def options(self): + if self.entity_description.device_class == SensorDeviceClass.ENUM: + options = sorted( + list( + set( + self._device.get_register_value_options( + self.entity_description.key + ).values() + ) + ) + ) + cur_value = self._device.get_register_value_description( + self.entity_description.key + ) + if cur_value not in options: + options.append(cur_value) + + return options