mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
ZHA Component: Correct AttributeUpdated signal in Thermostat climate entity, ThermostatClusterHandler and ThermostatHVACAction sensor entity (#101725)
* initial * change other Thermostat climate entities * remove AttributeUpdateRecord
This commit is contained in:
parent
71ddb282d2
commit
5290396731
@ -367,10 +367,10 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
||||
self._thrm, SIGNAL_ATTR_UPDATED, self.async_attribute_updated
|
||||
)
|
||||
|
||||
async def async_attribute_updated(self, record):
|
||||
async def async_attribute_updated(self, attr_id, attr_name, value):
|
||||
"""Handle attribute update from device."""
|
||||
if (
|
||||
record.attr_name in (ATTR_OCCP_COOL_SETPT, ATTR_OCCP_HEAT_SETPT)
|
||||
attr_name in (ATTR_OCCP_COOL_SETPT, ATTR_OCCP_HEAT_SETPT)
|
||||
and self.preset_mode == PRESET_AWAY
|
||||
):
|
||||
# occupancy attribute is an unreportable attribute, but if we get
|
||||
@ -379,7 +379,7 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
||||
if await self._thrm.get_occupancy() is True:
|
||||
self._preset = PRESET_NONE
|
||||
|
||||
self.debug("Attribute '%s' = %s update", record.attr_name, record.value)
|
||||
self.debug("Attribute '%s' = %s update", attr_name, value)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
@ -609,24 +609,24 @@ class MoesThermostat(Thermostat):
|
||||
"""Return only the heat mode, because the device can't be turned off."""
|
||||
return [HVACMode.HEAT]
|
||||
|
||||
async def async_attribute_updated(self, record):
|
||||
async def async_attribute_updated(self, attr_id, attr_name, value):
|
||||
"""Handle attribute update from device."""
|
||||
if record.attr_name == "operation_preset":
|
||||
if record.value == 0:
|
||||
if attr_name == "operation_preset":
|
||||
if value == 0:
|
||||
self._preset = PRESET_AWAY
|
||||
if record.value == 1:
|
||||
if value == 1:
|
||||
self._preset = PRESET_SCHEDULE
|
||||
if record.value == 2:
|
||||
if value == 2:
|
||||
self._preset = PRESET_NONE
|
||||
if record.value == 3:
|
||||
if value == 3:
|
||||
self._preset = PRESET_COMFORT
|
||||
if record.value == 4:
|
||||
if value == 4:
|
||||
self._preset = PRESET_ECO
|
||||
if record.value == 5:
|
||||
if value == 5:
|
||||
self._preset = PRESET_BOOST
|
||||
if record.value == 6:
|
||||
if value == 6:
|
||||
self._preset = PRESET_COMPLEX
|
||||
await super().async_attribute_updated(record)
|
||||
await super().async_attribute_updated(attr_id, attr_name, value)
|
||||
|
||||
async def async_preset_handler(self, preset: str, enable: bool = False) -> None:
|
||||
"""Set the preset mode."""
|
||||
@ -688,22 +688,22 @@ class BecaThermostat(Thermostat):
|
||||
"""Return only the heat mode, because the device can't be turned off."""
|
||||
return [HVACMode.HEAT]
|
||||
|
||||
async def async_attribute_updated(self, record):
|
||||
async def async_attribute_updated(self, attr_id, attr_name, value):
|
||||
"""Handle attribute update from device."""
|
||||
if record.attr_name == "operation_preset":
|
||||
if record.value == 0:
|
||||
if attr_name == "operation_preset":
|
||||
if value == 0:
|
||||
self._preset = PRESET_AWAY
|
||||
if record.value == 1:
|
||||
if value == 1:
|
||||
self._preset = PRESET_SCHEDULE
|
||||
if record.value == 2:
|
||||
if value == 2:
|
||||
self._preset = PRESET_NONE
|
||||
if record.value == 4:
|
||||
if value == 4:
|
||||
self._preset = PRESET_ECO
|
||||
if record.value == 5:
|
||||
if value == 5:
|
||||
self._preset = PRESET_BOOST
|
||||
if record.value == 7:
|
||||
if value == 7:
|
||||
self._preset = PRESET_TEMP_MANUAL
|
||||
await super().async_attribute_updated(record)
|
||||
await super().async_attribute_updated(attr_id, attr_name, value)
|
||||
|
||||
async def async_preset_handler(self, preset: str, enable: bool = False) -> None:
|
||||
"""Set the preset mode."""
|
||||
@ -783,20 +783,20 @@ class ZONNSMARTThermostat(Thermostat):
|
||||
]
|
||||
self._supported_flags |= ClimateEntityFeature.PRESET_MODE
|
||||
|
||||
async def async_attribute_updated(self, record):
|
||||
async def async_attribute_updated(self, attr_id, attr_name, value):
|
||||
"""Handle attribute update from device."""
|
||||
if record.attr_name == "operation_preset":
|
||||
if record.value == 0:
|
||||
if attr_name == "operation_preset":
|
||||
if value == 0:
|
||||
self._preset = PRESET_SCHEDULE
|
||||
if record.value == 1:
|
||||
if value == 1:
|
||||
self._preset = PRESET_NONE
|
||||
if record.value == 2:
|
||||
if value == 2:
|
||||
self._preset = self.PRESET_HOLIDAY
|
||||
if record.value == 3:
|
||||
if value == 3:
|
||||
self._preset = self.PRESET_HOLIDAY
|
||||
if record.value == 4:
|
||||
if value == 4:
|
||||
self._preset = self.PRESET_FROST
|
||||
await super().async_attribute_updated(record)
|
||||
await super().async_attribute_updated(attr_id, attr_name, value)
|
||||
|
||||
async def async_preset_handler(self, preset: str, enable: bool = False) -> None:
|
||||
"""Set the preset mode."""
|
||||
|
@ -5,7 +5,6 @@ https://home-assistant.io/integrations/zha/
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import namedtuple
|
||||
from typing import Any
|
||||
|
||||
from zigpy.zcl.clusters import hvac
|
||||
@ -21,7 +20,6 @@ from ..const import (
|
||||
)
|
||||
from . import AttrReportConfig, ClusterHandler
|
||||
|
||||
AttributeUpdateRecord = namedtuple("AttributeUpdateRecord", "attr_id, attr_name, value")
|
||||
REPORT_CONFIG_CLIMATE = (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 25)
|
||||
REPORT_CONFIG_CLIMATE_DEMAND = (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 5)
|
||||
REPORT_CONFIG_CLIMATE_DISCRETE = (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 1)
|
||||
@ -235,7 +233,9 @@ class ThermostatClusterHandler(ClusterHandler):
|
||||
)
|
||||
self.async_send_signal(
|
||||
f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}",
|
||||
AttributeUpdateRecord(attrid, attr_name, value),
|
||||
attrid,
|
||||
attr_name,
|
||||
value,
|
||||
)
|
||||
|
||||
async def async_set_operation_mode(self, mode) -> bool:
|
||||
|
@ -854,11 +854,6 @@ class ThermostatHVACAction(Sensor, id_suffix="hvac_action"):
|
||||
return HVACAction.IDLE
|
||||
return HVACAction.OFF
|
||||
|
||||
@callback
|
||||
def async_set_state(self, *args, **kwargs) -> None:
|
||||
"""Handle state update from cluster handler."""
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
@MULTI_MATCH(
|
||||
cluster_handler_names={CLUSTER_HANDLER_THERMOSTAT},
|
||||
|
Loading…
x
Reference in New Issue
Block a user