mirror of
https://github.com/Andre0512/hon.git
synced 2025-07-07 19:40:32 +00:00
Get program name from prCode MQTT update
Fix SensorDeviceClass for Current Electricity Used
This commit is contained in:
parent
d76f3bddc7
commit
46433e4516
|
@ -81,7 +81,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||||
key="currentElectricityUsed",
|
key="currentElectricityUsed",
|
||||||
name="Current Electricity Used",
|
name="Current Electricity Used",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
icon="mdi:lightning-bolt",
|
icon="mdi:lightning-bolt",
|
||||||
translation_key="energy_current",
|
translation_key="energy_current",
|
||||||
|
@ -180,7 +180,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||||
translation_key="temperature",
|
translation_key="temperature",
|
||||||
),
|
),
|
||||||
HonSensorEntityDescription(
|
HonSensorEntityDescription(
|
||||||
key="programName",
|
key="prCode",
|
||||||
name="Program",
|
name="Program",
|
||||||
icon="mdi:play",
|
icon="mdi:play",
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
@ -834,10 +834,11 @@ class HonSensorEntity(HonEntity, SensorEntity):
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self, update: bool = True) -> None:
|
def _handle_coordinator_update(self, update: bool = True) -> None:
|
||||||
value = self._device.get(self.entity_description.key, "")
|
value = self._device.get(self.entity_description.key, "")
|
||||||
if self.entity_description.key == "programName":
|
if self.entity_description.key == "prCode":
|
||||||
if not (options := self._device.settings.get("startProgram.program")):
|
if not (options := self._device.settings.get("startProgram.program")):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
self._attr_options = options.values + ["No Program"]
|
self._attr_options = [*options.values, "No Program"]
|
||||||
|
value = options.ids.get(value)
|
||||||
elif self.entity_description.option_list is not None:
|
elif self.entity_description.option_list is not None:
|
||||||
self._attr_options = list(self.entity_description.option_list.values())
|
self._attr_options = list(self.entity_description.option_list.values())
|
||||||
value = str(get_readable(self.entity_description, value))
|
value = str(get_readable(self.entity_description, value))
|
||||||
|
@ -874,3 +875,4 @@ class HonConfigSensorEntity(HonEntity, SensorEntity):
|
||||||
self._attr_native_value = value
|
self._attr_native_value = value
|
||||||
if update:
|
if update:
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue