Add power source to device and clean up zha listeners (#21174)

check available and add comments

ensure order on API test
This commit is contained in:
David F. Mulcahey authored and Paulus Schoutsen committed 2019-02-18 13:30:59 -08:00
1 parent 8b5aff63ae
commit d1fa341a78
12 files changed
+179 -58

No files matched your search

+3 -1
View File
@@ -174,6 +174,7 @@ async def async_test_device_join(
only trigger during device joins can be tested.
"""
from zigpy.zcl.foundation import Status
from zigpy.zcl.clusters.general import Basic
# create zigpy device mocking out the zigbee network operations
with patch(
'zigpy.zcl.Cluster.configure_reporting',
@@ -182,7 +183,8 @@ async def async_test_device_join(
'zigpy.zcl.Cluster.bind',
return_value=mock_coro([Status.SUCCESS, Status.SUCCESS])):
zigpy_device = await async_init_zigpy_device(
hass, [cluster_id], [], device_type, zha_gateway,
hass, [cluster_id, Basic.cluster_id], [], device_type,
zha_gateway,
ieee="00:0d:6f:00:0a:90:69:f7",
manufacturer="FakeMan{}".format(cluster_id),
model="FakeMod{}".format(cluster_id),
+10 -4
View File
@@ -17,14 +17,14 @@ from .common import async_init_zigpy_device
@pytest.fixture
async def zha_client(hass, config_entry, zha_gateway, hass_ws_client):
"""Test zha switch platform."""
from zigpy.zcl.clusters.general import OnOff
from zigpy.zcl.clusters.general import OnOff, Basic
# load the ZHA API
async_load_api(hass, Mock(), zha_gateway)
# create zigpy device
await async_init_zigpy_device(
hass, [OnOff.cluster_id], [], None, zha_gateway)
hass, [OnOff.cluster_id, Basic.cluster_id], [], None, zha_gateway)
# load up switch domain
await hass.config_entries.async_forward_entry_setup(
@@ -44,10 +44,16 @@ async def test_device_clusters(hass, config_entry, zha_gateway, zha_client):
msg = await zha_client.receive_json()
assert len(msg['result']) == 1
assert len(msg['result']) == 2
cluster_info = msg['result'][0]
cluster_infos = sorted(msg['result'], key=lambda k: k[ID])
cluster_info = cluster_infos[0]
assert cluster_info[TYPE] == IN
assert cluster_info[ID] == 0
assert cluster_info[NAME] == 'Basic'
cluster_info = cluster_infos[1]
assert cluster_info[TYPE] == IN
assert cluster_info[ID] == 6
assert cluster_info[NAME] == 'OnOff'
+4 -4
View File
@@ -11,13 +11,13 @@ async def test_binary_sensor(hass, config_entry, zha_gateway):
"""Test zha binary_sensor platform."""
from zigpy.zcl.clusters.security import IasZone
from zigpy.zcl.clusters.measurement import OccupancySensing
from zigpy.zcl.clusters.general import OnOff, LevelControl
from zigpy.zcl.clusters.general import OnOff, LevelControl, Basic
from zigpy.profiles.zha import DeviceType
# create zigpy devices
zigpy_device_zone = await async_init_zigpy_device(
hass,
[IasZone.cluster_id],
[IasZone.cluster_id, Basic.cluster_id],
[],
None,
zha_gateway
@@ -25,7 +25,7 @@ async def test_binary_sensor(hass, config_entry, zha_gateway):
zigpy_device_remote = await async_init_zigpy_device(
hass,
[],
[Basic.cluster_id],
[OnOff.cluster_id, LevelControl.cluster_id],
DeviceType.LEVEL_CONTROL_SWITCH,
zha_gateway,
@@ -36,7 +36,7 @@ async def test_binary_sensor(hass, config_entry, zha_gateway):
zigpy_device_occupancy = await async_init_zigpy_device(
hass,
[OccupancySensing.cluster_id],
[OccupancySensing.cluster_id, Basic.cluster_id],
[],
None,
zha_gateway,
+2 -1
View File
@@ -17,11 +17,12 @@ from .common import (
async def test_fan(hass, config_entry, zha_gateway):
"""Test zha fan platform."""
from zigpy.zcl.clusters.hvac import Fan
from zigpy.zcl.clusters.general import Basic
from zigpy.zcl.foundation import Status
# create zigpy device
zigpy_device = await async_init_zigpy_device(
hass, [Fan.cluster_id], [], None, zha_gateway)
hass, [Fan.cluster_id, Basic.cluster_id], [], None, zha_gateway)
# load up fan domain
await hass.config_entries.async_forward_entry_setup(
+3 -3
View File
@@ -14,13 +14,13 @@ OFF = 0
async def test_light(hass, config_entry, zha_gateway):
"""Test zha light platform."""
from zigpy.zcl.clusters.general import OnOff, LevelControl
from zigpy.zcl.clusters.general import OnOff, LevelControl, Basic
from zigpy.profiles.zha import DeviceType
# create zigpy devices
zigpy_device_on_off = await async_init_zigpy_device(
hass,
[OnOff.cluster_id],
[OnOff.cluster_id, Basic.cluster_id],
[],
DeviceType.ON_OFF_LIGHT,
zha_gateway
@@ -28,7 +28,7 @@ async def test_light(hass, config_entry, zha_gateway):
zigpy_device_level = await async_init_zigpy_device(
hass,
[OnOff.cluster_id, LevelControl.cluster_id],
[OnOff.cluster_id, LevelControl.cluster_id, Basic.cluster_id],
[],
DeviceType.ON_OFF_LIGHT,
zha_gateway,
+2 -1
View File
@@ -86,6 +86,7 @@ async def async_build_devices(hass, zha_gateway, config_entry, cluster_ids):
A dict containing relevant device info for testing is returned. It contains
the entity id, zigpy device, and the zigbee cluster for the sensor.
"""
from zigpy.zcl.clusters.general import Basic
device_infos = {}
counter = 0
for cluster_id in cluster_ids:
@@ -93,7 +94,7 @@ async def async_build_devices(hass, zha_gateway, config_entry, cluster_ids):
device_infos[cluster_id] = {"zigpy_device": None}
device_infos[cluster_id]["zigpy_device"] = await \
async_init_zigpy_device(
hass, [cluster_id], [], None, zha_gateway,
hass, [cluster_id, Basic.cluster_id], [], None, zha_gateway,
ieee="{}0:15:8d:00:02:32:4f:32".format(counter),
manufacturer="Fake{}".format(cluster_id),
model="FakeModel{}".format(cluster_id))
+2 -2
View File
@@ -14,12 +14,12 @@ OFF = 0
async def test_switch(hass, config_entry, zha_gateway):
"""Test zha switch platform."""
from zigpy.zcl.clusters.general import OnOff
from zigpy.zcl.clusters.general import OnOff, Basic
from zigpy.zcl.foundation import Status
# create zigpy device
zigpy_device = await async_init_zigpy_device(
hass, [OnOff.cluster_id], [], None, zha_gateway)
hass, [OnOff.cluster_id, Basic.cluster_id], [], None, zha_gateway)
# load up switch domain
await hass.config_entries.async_forward_entry_setup(