Fix ZHA cover initial state (#71083)
This commit is contained in:
parent
7f094a928b
commit
f184f9e142
4 changed files with 10 additions and 18 deletions
|
@ -84,7 +84,7 @@ class IasAce(ZigbeeChannel):
|
||||||
@callback
|
@callback
|
||||||
def cluster_command(self, tsn, command_id, args) -> None:
|
def cluster_command(self, tsn, command_id, args) -> None:
|
||||||
"""Handle commands received to this cluster."""
|
"""Handle commands received to this cluster."""
|
||||||
self.warning(
|
self.debug(
|
||||||
"received command %s", self._cluster.server_commands[command_id].name
|
"received command %s", self._cluster.server_commands[command_id].name
|
||||||
)
|
)
|
||||||
self.command_map[command_id](*args)
|
self.command_map[command_id](*args)
|
||||||
|
@ -120,7 +120,7 @@ class IasAce(ZigbeeChannel):
|
||||||
code != self.panel_code
|
code != self.panel_code
|
||||||
and self.armed_state != AceCluster.PanelStatus.Panel_Disarmed
|
and self.armed_state != AceCluster.PanelStatus.Panel_Disarmed
|
||||||
):
|
):
|
||||||
self.warning("Invalid code supplied to IAS ACE")
|
self.debug("Invalid code supplied to IAS ACE")
|
||||||
self.invalid_tries += 1
|
self.invalid_tries += 1
|
||||||
zigbee_reply = self.arm_response(
|
zigbee_reply = self.arm_response(
|
||||||
AceCluster.ArmNotification.Invalid_Arm_Disarm_Code
|
AceCluster.ArmNotification.Invalid_Arm_Disarm_Code
|
||||||
|
@ -131,12 +131,12 @@ class IasAce(ZigbeeChannel):
|
||||||
self.armed_state == AceCluster.PanelStatus.Panel_Disarmed
|
self.armed_state == AceCluster.PanelStatus.Panel_Disarmed
|
||||||
and self.alarm_status == AceCluster.AlarmStatus.No_Alarm
|
and self.alarm_status == AceCluster.AlarmStatus.No_Alarm
|
||||||
):
|
):
|
||||||
self.warning("IAS ACE already disarmed")
|
self.debug("IAS ACE already disarmed")
|
||||||
zigbee_reply = self.arm_response(
|
zigbee_reply = self.arm_response(
|
||||||
AceCluster.ArmNotification.Already_Disarmed
|
AceCluster.ArmNotification.Already_Disarmed
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.warning("Disarming all IAS ACE zones")
|
self.debug("Disarming all IAS ACE zones")
|
||||||
zigbee_reply = self.arm_response(
|
zigbee_reply = self.arm_response(
|
||||||
AceCluster.ArmNotification.All_Zones_Disarmed
|
AceCluster.ArmNotification.All_Zones_Disarmed
|
||||||
)
|
)
|
||||||
|
@ -177,12 +177,12 @@ class IasAce(ZigbeeChannel):
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Arm the panel with the specified statuses."""
|
"""Arm the panel with the specified statuses."""
|
||||||
if self.code_required_arm_actions and code != self.panel_code:
|
if self.code_required_arm_actions and code != self.panel_code:
|
||||||
self.warning("Invalid code supplied to IAS ACE")
|
self.debug("Invalid code supplied to IAS ACE")
|
||||||
zigbee_reply = self.arm_response(
|
zigbee_reply = self.arm_response(
|
||||||
AceCluster.ArmNotification.Invalid_Arm_Disarm_Code
|
AceCluster.ArmNotification.Invalid_Arm_Disarm_Code
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.warning("Arming all IAS ACE zones")
|
self.debug("Arming all IAS ACE zones")
|
||||||
self.armed_state = panel_status
|
self.armed_state = panel_status
|
||||||
zigbee_reply = self.arm_response(armed_type)
|
zigbee_reply = self.arm_response(armed_type)
|
||||||
return zigbee_reply
|
return zigbee_reply
|
||||||
|
|
|
@ -240,14 +240,14 @@ class ZHAGateway:
|
||||||
async def async_initialize_devices_and_entities(self) -> None:
|
async def async_initialize_devices_and_entities(self) -> None:
|
||||||
"""Initialize devices and load entities."""
|
"""Initialize devices and load entities."""
|
||||||
|
|
||||||
_LOGGER.warning("Loading all devices")
|
_LOGGER.debug("Loading all devices")
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
*(dev.async_initialize(from_cache=True) for dev in self.devices.values())
|
*(dev.async_initialize(from_cache=True) for dev in self.devices.values())
|
||||||
)
|
)
|
||||||
|
|
||||||
async def fetch_updated_state() -> None:
|
async def fetch_updated_state() -> None:
|
||||||
"""Fetch updated state for mains powered devices."""
|
"""Fetch updated state for mains powered devices."""
|
||||||
_LOGGER.warning("Fetching current state for mains powered devices")
|
_LOGGER.debug("Fetching current state for mains powered devices")
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
*(
|
*(
|
||||||
dev.async_initialize(from_cache=False)
|
dev.async_initialize(from_cache=False)
|
||||||
|
|
|
@ -206,10 +206,8 @@ class ZhaEntity(BaseZhaEntity, RestoreEntity):
|
||||||
signal_override=True,
|
signal_override=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.zha_device.is_mains_powered:
|
if last_state := await self.async_get_last_state():
|
||||||
# mains powered devices will get real time state
|
self.async_restore_last_state(last_state)
|
||||||
if last_state := await self.async_get_last_state():
|
|
||||||
self.async_restore_last_state(last_state)
|
|
||||||
|
|
||||||
self.async_accept_signal(
|
self.async_accept_signal(
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -86,12 +86,6 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
|
||||||
self._channel.data_cache[self._attr_name] = self._enum[option.replace(" ", "_")]
|
self._channel.data_cache[self._attr_name] = self._enum[option.replace(" ", "_")]
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
|
||||||
"""Run when about to be added to hass."""
|
|
||||||
await super().async_added_to_hass()
|
|
||||||
if last_state := await self.async_get_last_state():
|
|
||||||
self.async_restore_last_state(last_state)
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_restore_last_state(self, last_state) -> None:
|
def async_restore_last_state(self, last_state) -> None:
|
||||||
"""Restore previous state."""
|
"""Restore previous state."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue