Skip to content

Commit

Permalink
Better names, better comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
konistehrad committed Dec 11, 2023
1 parent 7d12976 commit 0cff019
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
11 changes: 7 additions & 4 deletions bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import bellows.multicast
import bellows.types as t
from bellows.zigbee import repairs
from bellows.zigbee.device import EZSPEndpoint, EZSPTestEndpoint
from bellows.zigbee.device import EZSPComplexEndpoint, EZSPSimpleEndpoint
import bellows.zigbee.util as util

APS_ACK_TIMEOUT = 120
Expand Down Expand Up @@ -215,13 +215,16 @@ async def start_network(self):
)
self.devices[self.state.node_info.ieee] = ezsp_device

# The coordinator device does not respond to attribute reads
# The coordinator device does not respond to attribute reads, so we
# have to divine the internal NCP state. If endpoints were explicitly
# given, create complex endpoints from the ZDO descriptors, otherwise
# assume a single endpoint at index 1
if len(self._created_device_endpoints) > 0:
for zdo_desc in self._created_device_endpoints:
ep = EZSPEndpoint(ezsp_device, zdo_desc)
ep = EZSPComplexEndpoint(ezsp_device, zdo_desc)
ezsp_device.endpoints[zdo_desc.endpoint] = ep
else:
ezsp_device.endpoints[1] = EZSPTestEndpoint(ezsp_device, 1)
ezsp_device.endpoints[1] = EZSPSimpleEndpoint(ezsp_device, 1)

ezsp_device.model = ezsp_device.endpoints[1].model
ezsp_device.manufacturer = ezsp_device.endpoints[1].manufacturer
Expand Down
8 changes: 2 additions & 6 deletions bellows/zigbee/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
LOGGER = logging.getLogger(__name__)


class BaseEZSPEndpoint(zigpy.endpoint.Endpoint):
class EZSPSimpleEndpoint(zigpy.endpoint.Endpoint):
@property
def manufacturer(self) -> str:
"""Manufacturer."""
Expand Down Expand Up @@ -59,7 +59,7 @@ async def remove_from_group(self, grp_id: int) -> t.EmberStatus:
return status


class EZSPEndpoint(BaseEZSPEndpoint):
class EZSPComplexEndpoint(EZSPSimpleEndpoint):
def __init__(self, device, descriptor: zdo_t.SimpleDescriptor) -> None:
self._desc = descriptor
super().__init__(device, descriptor.endpoint)
Expand Down Expand Up @@ -90,7 +90,3 @@ async def initialize(self) -> None:
self.add_output_cluster(cluster)

Check warning on line 90 in bellows/zigbee/device.py

View check run for this annotation

Codecov / codecov/patch

bellows/zigbee/device.py#L89-L90

Added lines #L89 - L90 were not covered by tests

self.status = zigpy.endpoint.Status.ENDPOINT_INACTIVE

Check warning on line 92 in bellows/zigbee/device.py

View check run for this annotation

Codecov / codecov/patch

bellows/zigbee/device.py#L92

Added line #L92 was not covered by tests


class EZSPTestEndpoint(BaseEZSPEndpoint):
pass
2 changes: 1 addition & 1 deletion tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ async def test_shutdown(app):
@pytest.fixture
def coordinator(app, ieee):
dev = zigpy.device.Device(app, ieee, 0x0000)
dev.endpoints[1] = bellows.zigbee.device.EZSPTestEndpoint(dev, 1)
dev.endpoints[1] = bellows.zigbee.device.EZSPSimpleEndpoint(dev, 1)
dev.model = dev.endpoints[1].model
dev.manufacturer = dev.endpoints[1].manufacturer

Expand Down

0 comments on commit 0cff019

Please sign in to comment.