Skip to content

Commit e0f9938

Browse files
committed
Fix startup
1 parent 073e368 commit e0f9938

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

bellows/ezsp/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ async def get_supported_firmware_features(
644644
bytes([custom_commands.CustomCommand.CMD_GET_SUPPORTED_FEATURES]),
645645
)
646646
except InvalidCommandError:
647-
return custom_commands.SupportedCustomFeatures(0)
647+
return custom_commands.FirmwareFeatures(0)
648648

649-
features, _ = custom_commands.SupportedCustomFeatures.deserialize(rsp_data)
649+
features, _ = custom_commands.FirmwareFeatures.deserialize(rsp_data)
650650
return features

bellows/zigbee/application.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import bellows.multicast
3838
import bellows.types as t
3939
from bellows.zigbee import repairs
40-
from bellows.zigbee.device import EZSPEndpoint
40+
from bellows.zigbee.device import EZSPEndpoint, EZSPGroupEndpoint
4141
import bellows.zigbee.util as util
4242

4343
APS_ACK_TIMEOUT = 120
@@ -205,14 +205,14 @@ async def start_network(self):
205205
ezsp.add_callback(self.ezsp_callback_handler)
206206
self.controller_event.set()
207207

208-
custom_features = await self._ezsp.get_supported_custom_features()
208+
custom_features = await self._ezsp.get_supported_firmware_features()
209209
LOGGER.debug("Supported custom firmware features: %r", custom_features)
210210

211211
if FirmwareFeatures.MEMBER_OF_ALL_GROUPS in custom_features:
212212
# If the firmware passes through all incoming group messages, do nothing
213-
endpoint_cls = zigpy.endpoint.Endpoint
214-
else:
215213
endpoint_cls = EZSPEndpoint
214+
else:
215+
endpoint_cls = EZSPGroupEndpoint
216216

217217
ezsp_device = zigpy.device.Device(
218218
application=self,
@@ -224,7 +224,7 @@ async def start_network(self):
224224
# The coordinator device does not respond to attribute reads so we have to
225225
# divine the internal NCP state.
226226
for zdo_desc in self._created_device_endpoints:
227-
ep = endpoint_cls(ezsp_device, zdo_desc.endpoint, zdo_desc)
227+
ep = endpoint_cls.from_descriptor(ezsp_device, zdo_desc.endpoint, zdo_desc)
228228
ezsp_device.endpoints[zdo_desc.endpoint] = ep
229229
ezsp_device.model = ep.model
230230
ezsp_device.manufacturer = ep.manufacturer

bellows/zigbee/device.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,32 @@
2121

2222

2323
class EZSPEndpoint(zigpy.endpoint.Endpoint):
24-
def __init__(
25-
self,
24+
@classmethod
25+
def from_descriptor(
26+
cls,
2627
device: zigpy.device.Device,
2728
endpoint_id: int,
2829
descriptor: zdo_t.SimpleDescriptor,
2930
) -> None:
30-
super().__init__(device, endpoint_id)
31+
ep = cls(device, endpoint_id)
32+
ep.profile_id = descriptor.profile
3133

32-
self.profile_id = descriptor.profile
33-
34-
if self.profile_id in PROFILE_TO_DEVICE_TYPE:
35-
self.device_type = PROFILE_TO_DEVICE_TYPE[self.profile_id](
34+
if ep.profile_id in PROFILE_TO_DEVICE_TYPE:
35+
ep.device_type = PROFILE_TO_DEVICE_TYPE[ep.profile_id](
3636
descriptor.device_type
3737
)
3838
else:
39-
self.device_type = descriptor.device_type
39+
ep.device_type = descriptor.device_type
4040

4141
for cluster in descriptor.input_clusters:
42-
self.add_input_cluster(cluster)
42+
ep.add_input_cluster(cluster)
4343

4444
for cluster in descriptor.output_clusters:
45-
self.add_output_cluster(cluster)
45+
ep.add_output_cluster(cluster)
46+
47+
ep.status = zigpy.endpoint.Status.ZDO_INIT
4648

47-
self.status = zigpy.endpoint.Status.ZDO_INIT
49+
return ep
4850

4951
@property
5052
def manufacturer(self) -> str:
@@ -56,6 +58,8 @@ def model(self) -> str:
5658
"""Model."""
5759
return "EZSP"
5860

61+
62+
class EZSPGroupEndpoint(EZSPEndpoint):
5963
async def add_to_group(self, grp_id: int, name: str = None) -> t.EmberStatus:
6064
if grp_id in self.member_of:
6165
return t.EmberStatus.SUCCESS

0 commit comments

Comments
 (0)