Remove zigpy monkey patching (#43456)

* Use event handler for incoming messages from zigpy

* Bump up zha dependency
This commit is contained in:
Alexei Chetroi 2020-11-20 20:02:52 -05:00 committed by GitHub
parent 43955d3aa8
commit e32669a2d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 31 deletions

View file

@ -1057,7 +1057,6 @@ omit =
homeassistant/components/zha/core/device.py
homeassistant/components/zha/core/gateway.py
homeassistant/components/zha/core/helpers.py
homeassistant/components/zha/core/patches.py
homeassistant/components/zha/core/registries.py
homeassistant/components/zha/core/typing.py
homeassistant/components/zha/entity.py

View file

@ -82,7 +82,6 @@ from .device import (
ZHADevice,
)
from .group import GroupMember, ZHAGroup
from .patches import apply_application_controller_patch
from .registries import GROUP_ENTITY_DOMAINS
from .store import async_get_registry
from .typing import ZhaGroupType, ZigpyEndpointType, ZigpyGroupType
@ -155,7 +154,6 @@ class ZHAGateway:
)
raise ConfigEntryNotReady from exception
apply_application_controller_patch(self)
self.application_controller.add_listener(self)
self.application_controller.groups.add_listener(self)
self._hass.data[DATA_ZHA][DATA_ZHA_GATEWAY] = self
@ -506,13 +504,6 @@ class ZHAGateway:
self._groups[zigpy_group.group_id] = zha_group
return zha_group
@callback
def async_device_became_available(
self, sender, profile, cluster, src_ep, dst_ep, message
):
"""Handle tasks when a device becomes available."""
self.async_update_device(sender, available=True)
@callback
def async_update_device(
self, sender: zigpy_dev.Device, available: bool = True
@ -639,6 +630,19 @@ class ZHAGateway:
unsubscribe()
await self.application_controller.pre_shutdown()
def handle_message(
self,
sender: zigpy_dev.Device,
profile: int,
cluster: int,
src_ep: int,
dst_ep: int,
message: bytes,
) -> None:
"""Handle message from a device Event handler."""
if sender.ieee in self.devices and not self.devices[sender.ieee].available:
self.async_update_device(sender, available=True)
@callback
def async_capture_log_levels():

View file

@ -1,18 +0,0 @@
"""Patch functions for Zigbee Home Automation."""
def apply_application_controller_patch(zha_gateway):
"""Apply patches to ZHA objects."""
# Patch handle_message until zigpy can provide an event here
def handle_message(sender, profile, cluster, src_ep, dst_ep, message):
"""Handle message from a device."""
if (
sender.ieee in zha_gateway.devices
and not zha_gateway.devices[sender.ieee].available
):
zha_gateway.async_device_became_available(
sender, profile, cluster, src_ep, dst_ep, message
)
return sender.handle_message(profile, cluster, src_ep, dst_ep, message)
zha_gateway.application_controller.handle_message = handle_message

View file

@ -9,7 +9,7 @@
"zha-quirks==0.0.46",
"zigpy-cc==0.5.2",
"zigpy-deconz==0.11.0",
"zigpy==0.27.1",
"zigpy==0.28.0",
"zigpy-xbee==0.13.0",
"zigpy-zigate==0.7.3",
"zigpy-znp==0.2.2"

View file

@ -2362,7 +2362,7 @@ zigpy-zigate==0.7.3
zigpy-znp==0.2.2
# homeassistant.components.zha
zigpy==0.27.1
zigpy==0.28.0
# homeassistant.components.zoneminder
zm-py==0.4.0

View file

@ -1146,4 +1146,4 @@ zigpy-zigate==0.7.3
zigpy-znp==0.2.2
# homeassistant.components.zha
zigpy==0.27.1
zigpy==0.28.0