Add more HomeKit device enumeration tests (#22194)

* Test that Aqara Gateway, Ecobee 3 and Lennox E30 is correctly enumerated

* Move json to fixtures directory

* Move IO to executor
This commit is contained in:
Jc2k 2019-03-30 10:21:11 +00:00 committed by Martin Hjelmare
parent 1a39fb4de7
commit 906f0113ad
10 changed files with 2352 additions and 9 deletions

View file

@ -1,244 +0,0 @@
[
{
"aid": 1,
"services": [
{
"characteristics": [
{
"format": "string",
"iid": 2,
"maxLen": 64,
"perms": [
"pr"
],
"type": "23",
"value": "Koogeek-LS1-20833F"
},
{
"format": "string",
"iid": 3,
"maxLen": 64,
"perms": [
"pr"
],
"type": "20",
"value": "Koogeek"
},
{
"format": "string",
"iid": 4,
"maxLen": 64,
"perms": [
"pr"
],
"type": "21",
"value": "LS1"
},
{
"format": "string",
"iid": 5,
"maxLen": 64,
"perms": [
"pr"
],
"type": "30",
"value": "AAAA011111111111"
},
{
"format": "bool",
"iid": 6,
"perms": [
"pw"
],
"type": "14"
},
{
"format": "string",
"iid": 23,
"perms": [
"pr"
],
"type": "52",
"value": "2.2.15"
}
],
"iid": 1,
"type": "3E"
},
{
"characteristics": [
{
"ev": false,
"format": "bool",
"iid": 8,
"perms": [
"pr",
"pw",
"ev"
],
"type": "25",
"value": false
},
{
"ev": false,
"format": "float",
"iid": 9,
"maxValue": 359,
"minStep": 1,
"minValue": 0,
"perms": [
"pr",
"pw",
"ev"
],
"type": "13",
"unit": "arcdegrees",
"value": 44
},
{
"ev": false,
"format": "float",
"iid": 10,
"maxValue": 100,
"minStep": 1,
"minValue": 0,
"perms": [
"pr",
"pw",
"ev"
],
"type": "2F",
"unit": "percentage",
"value": 0
},
{
"ev": false,
"format": "int",
"iid": 11,
"maxValue": 100,
"minStep": 1,
"minValue": 0,
"perms": [
"pr",
"pw",
"ev"
],
"type": "8",
"unit": "percentage",
"value": 100
},
{
"format": "string",
"iid": 12,
"maxLen": 64,
"perms": [
"pr"
],
"type": "23",
"value": "Light Strip"
}
],
"iid": 7,
"primary": true,
"type": "43"
},
{
"characteristics": [
{
"description": "TIMER_SETTINGS",
"format": "tlv8",
"iid": 14,
"perms": [
"pr",
"pw"
],
"type": "4aaaf942-0dec-11e5-b939-0800200c9a66",
"value": "AHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
],
"iid": 13,
"type": "4aaaf940-0dec-11e5-b939-0800200c9a66"
},
{
"characteristics": [
{
"description": "FW Upgrade supported types",
"format": "string",
"iid": 16,
"perms": [
"pr",
"hd"
],
"type": "151909D2-3802-11E4-916C-0800200C9A66",
"value": "url,data"
},
{
"description": "FW Upgrade URL",
"format": "string",
"iid": 17,
"maxLen": 256,
"perms": [
"pw",
"hd"
],
"type": "151909D1-3802-11E4-916C-0800200C9A66"
},
{
"description": "FW Upgrade Status",
"ev": false,
"format": "int",
"iid": 18,
"perms": [
"pr",
"ev",
"hd"
],
"type": "151909D6-3802-11E4-916C-0800200C9A66",
"value": 0
},
{
"description": "FW Upgrade Data",
"format": "data",
"iid": 19,
"perms": [
"pw",
"hd"
],
"type": "151909D7-3802-11E4-916C-0800200C9A66"
}
],
"hidden": true,
"iid": 15,
"type": "151909D0-3802-11E4-916C-0800200C9A66"
},
{
"characteristics": [
{
"description": "Timezone",
"format": "int",
"iid": 21,
"perms": [
"pr",
"pw"
],
"type": "151909D5-3802-11E4-916C-0800200C9A66",
"value": 0
},
{
"description": "Time value since Epoch",
"format": "int",
"iid": 22,
"perms": [
"pr",
"pw"
],
"type": "151909D4-3802-11E4-916C-0800200C9A66",
"value": 1550348623
}
],
"iid": 20,
"type": "151909D3-3802-11E4-916C-0800200C9A66"
}
]
}
]

View file

@ -0,0 +1,41 @@
"""
Regression tests for Aqara Gateway V3.
https://github.com/home-assistant/home-assistant/issues/20957
"""
from homeassistant.components.light import SUPPORT_BRIGHTNESS, SUPPORT_COLOR
from tests.components.homekit_controller.common import (
setup_accessories_from_file, setup_test_accessories, Helper
)
async def test_aqara_gateway_setup(hass):
"""Test that a Aqara Gateway can be correctly setup in HA."""
accessories = await setup_accessories_from_file(
hass, 'aqara_gateway.json')
pairing = await setup_test_accessories(hass, accessories)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
# Check that the light is correctly found and set up
alarm_id = "alarm_control_panel.aqara_hub_1563"
alarm = entity_registry.async_get(alarm_id)
assert alarm.unique_id == 'homekit-0000000123456789-66304'
alarm_helper = Helper(
hass, 'alarm_control_panel.aqara_hub_1563', pairing, accessories[0])
alarm_state = await alarm_helper.poll_and_get_state()
assert alarm_state.attributes['friendly_name'] == 'Aqara Hub-1563'
# Check that the light is correctly found and set up
light = entity_registry.async_get('light.aqara_hub_1563')
assert light.unique_id == 'homekit-0000000123456789-65792'
light_helper = Helper(
hass, 'light.aqara_hub_1563', pairing, accessories[0])
light_state = await light_helper.poll_and_get_state()
assert light_state.attributes['friendly_name'] == 'Aqara Hub-1563'
assert light_state.attributes['supported_features'] == (
SUPPORT_BRIGHTNESS | SUPPORT_COLOR
)

View file

@ -0,0 +1,43 @@
"""
Regression tests for Ecobee 3.
https://github.com/home-assistant/home-assistant/issues/15336
"""
from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE)
from tests.components.homekit_controller.common import (
setup_accessories_from_file, setup_test_accessories, Helper
)
async def test_ecobee3_setup(hass):
"""Test that a Ecbobee 3 can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, 'ecobee3.json')
pairing = await setup_test_accessories(hass, accessories)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
climate = entity_registry.async_get('climate.homew')
assert climate.unique_id == 'homekit-123456789012-16'
climate_helper = Helper(hass, 'climate.homew', pairing, accessories[0])
climate_state = await climate_helper.poll_and_get_state()
assert climate_state.attributes['friendly_name'] == 'HomeW'
assert climate_state.attributes['supported_features'] == (
SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
)
occ1 = entity_registry.async_get('binary_sensor.kitchen')
assert occ1.unique_id == 'homekit-AB1C-56'
occ1_helper = Helper(
hass, 'binary_sensor.kitchen', pairing, accessories[0])
occ1_state = await occ1_helper.poll_and_get_state()
assert occ1_state.attributes['friendly_name'] == 'Kitchen'
occ2 = entity_registry.async_get('binary_sensor.porch')
assert occ2.unique_id == 'homekit-AB2C-56'
occ3 = entity_registry.async_get('binary_sensor.basement')
assert occ3.unique_id == 'homekit-AB3C-56'

View file

@ -1,6 +1,5 @@
"""Make sure that existing Koogeek LS1 support isn't broken."""
import os
from datetime import timedelta
from unittest import mock
@ -19,8 +18,7 @@ LIGHT_ON = ('lightbulb', 'on')
async def test_koogeek_ls1_setup(hass):
"""Test that a Koogeek LS1 can be correctly setup in HA."""
profile_path = os.path.join(os.path.dirname(__file__), 'koogeek_ls1.json')
accessories = setup_accessories_from_file(profile_path)
accessories = await setup_accessories_from_file(hass, 'koogeek_ls1.json')
pairing = await setup_test_accessories(hass, accessories)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
@ -50,8 +48,7 @@ async def test_recover_from_failure(hass, utcnow, failure_cls):
See https://github.com/home-assistant/home-assistant/issues/18949
"""
profile_path = os.path.join(os.path.dirname(__file__), 'koogeek_ls1.json')
accessories = setup_accessories_from_file(profile_path)
accessories = await setup_accessories_from_file(hass, 'koogeek_ls1.json')
pairing = await setup_test_accessories(hass, accessories)
helper = Helper(hass, 'light.koogeek_ls1_20833f', pairing, accessories[0])

View file

@ -0,0 +1,29 @@
"""
Regression tests for Aqara Gateway V3.
https://github.com/home-assistant/home-assistant/issues/20885
"""
from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE)
from tests.components.homekit_controller.common import (
setup_accessories_from_file, setup_test_accessories, Helper
)
async def test_lennox_e30_setup(hass):
"""Test that a Lennox E30 can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, 'lennox_e30.json')
pairing = await setup_test_accessories(hass, accessories)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
climate = entity_registry.async_get('climate.lennox')
assert climate.unique_id == 'homekit-XXXXXXXX-100'
climate_helper = Helper(hass, 'climate.lennox', pairing, accessories[0])
climate_state = await climate_helper.poll_and_get_state()
assert climate_state.attributes['friendly_name'] == 'Lennox'
assert climate_state.attributes['supported_features'] == (
SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
)