Fix Plugwise schema name display and non_device_class icons (#36815)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Bouwe Westerdijk <11290930+bouwew@users.noreply.github.com>
This commit is contained in:
parent
6db5ff98ed
commit
29df13abe9
2 changed files with 12 additions and 2 deletions
|
@ -122,8 +122,7 @@ class PwThermostat(SmileGateway, ClimateEntity):
|
||||||
"""Return the device specific state attributes."""
|
"""Return the device specific state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
if self._schema_names:
|
if self._schema_names:
|
||||||
if len(self._schema_names) > 1:
|
attributes["available_schemas"] = self._schema_names
|
||||||
attributes["available_schemas"] = self._schema_names
|
|
||||||
if self._selected_schema:
|
if self._selected_schema:
|
||||||
attributes["selected_schema"] = self._selected_schema
|
attributes["selected_schema"] = self._selected_schema
|
||||||
return attributes
|
return attributes
|
||||||
|
|
|
@ -157,6 +157,13 @@ INDICATE_ACTIVE_LOCAL_DEVICE = [
|
||||||
"flame_state",
|
"flame_state",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CUSTOM_ICONS = {
|
||||||
|
"gas_consumed_interval": "mdi:fire",
|
||||||
|
"gas_consumed_cumulative": "mdi:fire",
|
||||||
|
"modulation_level": "mdi:percent",
|
||||||
|
"valve_position": "mdi:valve",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the Smile sensors from a config entry."""
|
"""Set up the Smile sensors from a config entry."""
|
||||||
|
@ -271,6 +278,7 @@ class PwThermostatSensor(SmileSensor, Entity):
|
||||||
"""Set up the Plugwise API."""
|
"""Set up the Plugwise API."""
|
||||||
super().__init__(api, coordinator, name, dev_id, sensor)
|
super().__init__(api, coordinator, name, dev_id, sensor)
|
||||||
|
|
||||||
|
self._icon = None
|
||||||
self._model = sensor_type[SENSOR_MAP_MODEL]
|
self._model = sensor_type[SENSOR_MAP_MODEL]
|
||||||
self._unit_of_measurement = sensor_type[SENSOR_MAP_UOM]
|
self._unit_of_measurement = sensor_type[SENSOR_MAP_UOM]
|
||||||
self._dev_class = sensor_type[SENSOR_MAP_DEVICE_CLASS]
|
self._dev_class = sensor_type[SENSOR_MAP_DEVICE_CLASS]
|
||||||
|
@ -292,6 +300,7 @@ class PwThermostatSensor(SmileSensor, Entity):
|
||||||
if self._unit_of_measurement == UNIT_PERCENTAGE:
|
if self._unit_of_measurement == UNIT_PERCENTAGE:
|
||||||
measurement = int(measurement)
|
measurement = int(measurement)
|
||||||
self._state = measurement
|
self._state = measurement
|
||||||
|
self._icon = CUSTOM_ICONS.get(self._sensor, self._icon)
|
||||||
|
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
@ -346,6 +355,7 @@ class PwPowerSensor(SmileSensor, Entity):
|
||||||
"""Set up the Plugwise API."""
|
"""Set up the Plugwise API."""
|
||||||
super().__init__(api, coordinator, name, dev_id, sensor)
|
super().__init__(api, coordinator, name, dev_id, sensor)
|
||||||
|
|
||||||
|
self._icon = None
|
||||||
self._model = model
|
self._model = model
|
||||||
if model is None:
|
if model is None:
|
||||||
self._model = sensor_type[SENSOR_MAP_MODEL]
|
self._model = sensor_type[SENSOR_MAP_MODEL]
|
||||||
|
@ -371,5 +381,6 @@ class PwPowerSensor(SmileSensor, Entity):
|
||||||
if self._unit_of_measurement == ENERGY_KILO_WATT_HOUR:
|
if self._unit_of_measurement == ENERGY_KILO_WATT_HOUR:
|
||||||
measurement = int(measurement / 1000)
|
measurement = int(measurement / 1000)
|
||||||
self._state = measurement
|
self._state = measurement
|
||||||
|
self._icon = CUSTOM_ICONS.get(self._sensor, self._icon)
|
||||||
|
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
Loading…
Add table
Reference in a new issue