Skip to content

Commit 05a5023

Browse files
authored
Merge pull request #212 from puddly/rc
0.19.2 Release
2 parents e67e3b0 + 2d3f7aa commit 05a5023

File tree

7 files changed

+40
-84
lines changed

7 files changed

+40
-84
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
python-version: [3.8, 3.9, "3.10"]
21+
python-version: ['3.8.14', '3.9.15', '3.10.8', '3.11.0']
2222
steps:
2323
- name: Check out code from GitHub
2424
uses: actions/checkout@v2
@@ -271,7 +271,7 @@ jobs:
271271
needs: prepare-base
272272
strategy:
273273
matrix:
274-
python-version: [3.8, 3.9, "3.10"]
274+
python-version: ['3.8.14', '3.9.15', '3.10.8', '3.11.0']
275275
name: >-
276276
Run tests Python ${{ matrix.python-version }}
277277
steps:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
- --safe
88
- --quiet
99

10-
- repo: https://gitlab.com/pycqa/flake8
10+
- repo: https://github.com/pycqa/flake8
1111
rev: 3.8.4
1212
hooks:
1313
- id: flake8

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
author_email="schmidt.d@aon.at",
2222
license="GPL-3.0",
2323
packages=find_packages(exclude=["tests"]),
24-
install_requires=["zigpy>=0.51.0"],
24+
install_requires=["zigpy>=0.52.1"],
2525
tests_require=["pytest", "asynctest"],
2626
)

tests/test_application.py

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytest
77
import zigpy.config
88
import zigpy.device
9-
import zigpy.neighbor
109
from zigpy.types import EUI64
1110
import zigpy.zdo.types as zdo_t
1211

@@ -357,52 +356,37 @@ async def test_restore_neighbours(app):
357356
"""Test neighbour restoration."""
358357

359358
# FFD, Rx on when idle
360-
desc_1 = zdo_t.NodeDescriptor(1, 64, 142, 0xBEEF, 82, 82, 0, 82, 0)
361-
device_1 = MagicMock()
362-
device_1.node_desc = desc_1
363-
device_1.ieee = sentinel.ieee_1
364-
device_1.nwk = 0x1111
365-
nei_1 = zigpy.neighbor.Neighbor(sentinel.nei_1, device_1)
359+
device_1 = app.add_device(nwk=0x0001, ieee=EUI64.convert("00:00:00:00:00:00:00:01"))
360+
device_1.node_desc = zdo_t.NodeDescriptor(1, 64, 142, 0xBEEF, 82, 82, 0, 82, 0)
366361

367362
# RFD, Rx on when idle
368-
desc_2 = zdo_t.NodeDescriptor(1, 64, 142, 0xBEEF, 82, 82, 0, 82, 0)
369-
device_2 = MagicMock()
370-
device_2.node_desc = desc_2
371-
device_2.ieee = sentinel.ieee_2
372-
device_2.nwk = 0x2222
373-
nei_2 = zigpy.neighbor.Neighbor(sentinel.nei_2, device_2)
374-
375-
# Missing node descriptor
376-
device_3 = MagicMock()
377-
device_3.node_desc = None
378-
device_3.ieee = sentinel.ieee_3
379-
device_3.nwk = 0x3333
380-
nei_3 = zigpy.neighbor.Neighbor(sentinel.nei_3, device_3)
363+
device_2 = app.add_device(nwk=0x0002, ieee=EUI64.convert("00:00:00:00:00:00:00:02"))
364+
device_2.node_desc = zdo_t.NodeDescriptor(1, 64, 142, 0xBEEF, 82, 82, 0, 82, 0)
381365

382-
# no device
383-
nei_4 = zigpy.neighbor.Neighbor(sentinel.nei_4, None)
366+
device_3 = app.add_device(nwk=0x0003, ieee=EUI64.convert("00:00:00:00:00:00:00:03"))
367+
device_3.node_desc = None
384368

385369
# RFD, Rx off when idle
386-
desc_5 = zdo_t.NodeDescriptor(2, 64, 128, 0xBEEF, 82, 82, 0, 82, 0)
387-
device_5 = MagicMock()
388-
device_5.node_desc = desc_5
389-
device_5.ieee = sentinel.ieee_5
390-
device_5.nwk = 0x5555
391-
nei_5 = zigpy.neighbor.Neighbor(sentinel.nei_5, device_5)
370+
device_5 = app.add_device(nwk=0x0005, ieee=EUI64.convert("00:00:00:00:00:00:00:05"))
371+
device_5.node_desc = zdo_t.NodeDescriptor(2, 64, 128, 0xBEEF, 82, 82, 0, 82, 0)
392372

393373
coord = MagicMock()
394-
coord.ieee = sentinel.coord_ieee
395-
coord.nwk = 0x0000
396-
neighbours = zigpy.neighbor.Neighbors(coord)
397-
neighbours.neighbors.append(nei_1)
398-
neighbours.neighbors.append(nei_2)
399-
neighbours.neighbors.append(nei_3)
400-
neighbours.neighbors.append(nei_4)
401-
neighbours.neighbors.append(nei_5)
402-
coord.neighbors = neighbours
403-
404-
p2 = patch.object(app, "_api", spec_set=zigpy_deconz.api.Deconz(None, None))
405-
with patch.object(app, "get_device", return_value=coord), p2 as api_mock:
374+
coord.ieee = EUI64.convert("aa:aa:aa:aa:aa:aa:aa:aa")
375+
376+
app.devices[coord.ieee] = coord
377+
app.state.node_info.ieee = coord.ieee
378+
379+
app.topology.neighbors[coord.ieee] = [
380+
zdo_t.Neighbor(ieee=device_1.ieee),
381+
zdo_t.Neighbor(ieee=device_2.ieee),
382+
zdo_t.Neighbor(ieee=device_3.ieee),
383+
zdo_t.Neighbor(ieee=EUI64.convert("00:00:00:00:00:00:00:04")),
384+
zdo_t.Neighbor(ieee=device_5.ieee),
385+
]
386+
387+
p = patch.object(app, "_api", spec_set=zigpy_deconz.api.Deconz(None, None))
388+
389+
with p as api_mock:
406390
api_mock.add_neighbour = AsyncMock()
407391
await app.restore_neighbours()
408392

@@ -415,7 +399,6 @@ async def test_delayed_scan():
415399
"""Delayed scan."""
416400

417401
coord = MagicMock()
418-
coord.neighbors.scan = AsyncMock()
419402
config = application.ControllerApplication.SCHEMA(
420403
{
421404
zigpy.config.CONF_DEVICE: {zigpy.config.CONF_DEVICE_PATH: "usb0"},
@@ -425,8 +408,9 @@ async def test_delayed_scan():
425408

426409
app = application.ControllerApplication(config)
427410
with patch.object(app, "get_device", return_value=coord):
428-
await app._delayed_neighbour_scan()
429-
assert coord.neighbors.scan.await_count == 1
411+
with patch.object(app, "topology", AsyncMock()):
412+
await app._delayed_neighbour_scan()
413+
app.topology.scan.assert_called_once_with(devices=[coord])
430414

431415

432416
@patch("zigpy_deconz.zigbee.application.CHANGE_NETWORK_WAIT", 0.001)

zigpy_deconz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# coding: utf-8
44
MAJOR_VERSION = 0
55
MINOR_VERSION = 19
6-
PATCH_VERSION = "1"
6+
PATCH_VERSION = "2"
77
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
88
__version__ = f"{__short_version__}.{PATCH_VERSION}"

zigpy_deconz/types.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import enum
44

55
import zigpy.types as zigpy_t
6+
from zigpy.types import bitmap8, bitmap16 # noqa: F401
67

78

89
def deserialize(data, schema):
@@ -128,33 +129,6 @@ class AddressMode(uint8_t, enum.Enum):
128129
NWK_AND_IEEE = 0x04
129130

130131

131-
def bitmap_factory(int_type: uint_t) -> enum.Flag:
132-
class _NewEnum(int_type, enum.Flag):
133-
# Rebind classmethods to our own class
134-
_missing_ = classmethod(enum.IntFlag._missing_.__func__)
135-
_create_pseudo_member_ = classmethod(
136-
enum.IntFlag._create_pseudo_member_.__func__
137-
)
138-
139-
__or__ = enum.IntFlag.__or__
140-
__and__ = enum.IntFlag.__and__
141-
__xor__ = enum.IntFlag.__xor__
142-
__ror__ = enum.IntFlag.__ror__
143-
__rand__ = enum.IntFlag.__rand__
144-
__rxor__ = enum.IntFlag.__rxor__
145-
__invert__ = enum.IntFlag.__invert__
146-
147-
return _NewEnum
148-
149-
150-
class bitmap8(bitmap_factory(uint8_t)):
151-
pass
152-
153-
154-
class bitmap16(bitmap_factory(uint16_t)):
155-
pass
156-
157-
158132
class DeconzSendDataFlags(bitmap8):
159133
NONE = 0x00
160134
NODE_ID = 0x01

zigpy_deconz/zigbee/application.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import zigpy.endpoint
1414
import zigpy.exceptions
1515
from zigpy.exceptions import FormationFailure, NetworkNotFormed
16-
import zigpy.neighbor
1716
import zigpy.state
1817
import zigpy.types
1918
import zigpy.util
@@ -126,7 +125,6 @@ async def start_network(self):
126125
self._config[zigpy.config.CONF_DEVICE][zigpy.config.CONF_DEVICE_PATH],
127126
)
128127

129-
coordinator.neighbors.add_context_listener(self._dblistener)
130128
self.devices[self.state.node_info.ieee] = coordinator
131129
if self._api.protocol_version >= PROTO_VER_NEIGBOURS:
132130
await self.restore_neighbours()
@@ -466,10 +464,13 @@ def handle_tx_confirm(self, req_id, status):
466464
async def restore_neighbours(self) -> None:
467465
"""Restore children."""
468466
coord = self.get_device(ieee=self.state.node_info.ieee)
469-
devices = (nei.device for nei in coord.neighbors)
470-
for device in devices:
471-
if device is None:
467+
468+
for neighbor in self.topology.neighbors[coord.ieee]:
469+
try:
470+
device = self.get_device(ieee=neighbor.ieee)
471+
except KeyError:
472472
continue
473+
473474
descr = device.node_desc
474475
LOGGER.debug(
475476
"device: 0x%04x - %s %s, FFD=%s, Rx_on_when_idle=%s",
@@ -498,7 +499,7 @@ async def _delayed_neighbour_scan(self) -> None:
498499
"""Scan coordinator's neighbours."""
499500
await asyncio.sleep(DELAY_NEIGHBOUR_SCAN_S)
500501
coord = self.get_device(ieee=self.state.node_info.ieee)
501-
await coord.neighbors.scan()
502+
await self.topology.scan(devices=[coord])
502503

503504
def connection_lost(self, exc: Exception) -> None:
504505
"""Lost connection."""
@@ -584,9 +585,6 @@ async def new(cls, application, ieee, nwk, version: int, device_path: str):
584585
from_dev = application.get_device(ieee=ieee)
585586
dev.status = from_dev.status
586587
dev.node_desc = from_dev.node_desc
587-
dev.neighbors = zigpy.neighbor.Neighbors(dev)
588-
for nei in from_dev.neighbors.neighbors:
589-
dev.neighbors.add_neighbor(nei.neighbor)
590588
for ep_id, from_ep in from_dev.endpoints.items():
591589
if not ep_id:
592590
continue # Skip ZDO

0 commit comments

Comments
 (0)