Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,13 @@ async def test_conbee_dev_add_to_group(app, nwk):
app._groups.add_group.return_value = group

conbee = application.ConBeeDevice(app, mock.sentinel.ieee, nwk)
conbee.endpoints = {0: mock.sentinel.zdo,
1: mock.sentinel.ep1,
2: mock.sentinel.ep2
}

await conbee.add_to_group(mock.sentinel.grp_id, mock.sentinel.grp_name)
assert group.add_member.call_count == 1
assert group.add_member.call_count == 2

assert app.groups.add_group.call_count == 1
assert app.groups.add_group.call_args[0][0] is mock.sentinel.grp_id
Expand All @@ -332,9 +336,13 @@ async def test_conbee_dev_remove_from_group(app, nwk):
app.groups[mock.sentinel.grp_id] = group
conbee = application.ConBeeDevice(app,
mock.sentinel.ieee, nwk)
conbee.endpoints = {0: mock.sentinel.zdo,
1: mock.sentinel.ep1,
2: mock.sentinel.ep2
}

await conbee.remove_from_group(mock.sentinel.grp_id)
assert group.remove_member.call_count == 1
assert group.remove_member.call_count == 2


def test_conbee_props(nwk):
Expand All @@ -355,7 +363,11 @@ async def test_conbee_new(app, nwk, monkeypatch):
assert mock_init.call_count == 1
mock_init.reset_mock()

app.devices[mock.sentinel.ieee] = mock.MagicMock()
mock_dev = mock.MagicMock()
mock_dev.endpoints = {0: mock.MagicMock(),
1: mock.MagicMock(),
22: mock.MagicMock()}
app.devices[mock.sentinel.ieee] = mock_dev
conbee = await application.ConBeeDevice.new(app, mock.sentinel.ieee, nwk)
assert isinstance(conbee, zigpy_deconz.zigbee.application.ConBeeDevice)
assert mock_init.call_count == 0
15 changes: 11 additions & 4 deletions zigpy_deconz/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,19 @@ class ConBeeDevice(zigpy.device.Device):
async def add_to_group(self, grp_id: int,
name: str = None) -> None:
group = self.application.groups.add_group(grp_id, name)
group.add_member(self)
return

for epid in self.endpoints:
if not epid:
continue # skip ZDO
group.add_member(self.endpoints[epid])
return [0]

async def remove_from_group(self, grp_id: int) -> None:
self.application.groups[grp_id].remove_member(self)
return
for epid in self.endpoints:
if not epid:
continue # skip ZDO
self.application.groups[grp_id].remove_member(self.endpoints[epid])
return [0]

@property
def manufacturer(self):
Expand Down