From 89ae88519d901b87ef5466d3ce7277aceee84d41 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 31 Oct 2021 09:19:37 -0500 Subject: [PATCH] Add additional test coverage for RYSE smartbridges with HK (#58746) --- .../test_ryse_smart_bridge.py | 68 ++ .../ryse_smart_bridge_four_shades.json | 1066 +++++++++++++++++ 2 files changed, 1134 insertions(+) create mode 100644 tests/fixtures/homekit_controller/ryse_smart_bridge_four_shades.json diff --git a/tests/components/homekit_controller/specific_devices/test_ryse_smart_bridge.py b/tests/components/homekit_controller/specific_devices/test_ryse_smart_bridge.py index ad5180658ad..e10e0ccd62a 100644 --- a/tests/components/homekit_controller/specific_devices/test_ryse_smart_bridge.py +++ b/tests/components/homekit_controller/specific_devices/test_ryse_smart_bridge.py @@ -71,3 +71,71 @@ async def test_ryse_smart_bridge_setup(hass): assert device.name == "RYSE SmartShade" assert device.model == "RYSE Shade" assert device.sw_version == "" + + +async def test_ryse_smart_bridge_four_shades_setup(hass): + """Test that a Ryse smart bridge with four shades can be correctly setup in HA.""" + accessories = await setup_accessories_from_file( + hass, "ryse_smart_bridge_four_shades.json" + ) + config_entry, pairing = await setup_test_accessories(hass, accessories) + + entity_registry = er.async_get(hass) + + cover_id = "cover.lr_left" + cover = entity_registry.async_get(cover_id) + assert cover.unique_id == "homekit-00:00:00:00:00:00-2-48" + + cover_id = "cover.lr_right" + cover = entity_registry.async_get(cover_id) + assert cover.unique_id == "homekit-00:00:00:00:00:00-3-48" + + cover_id = "cover.br_left" + cover = entity_registry.async_get(cover_id) + assert cover.unique_id == "homekit-00:00:00:00:00:00-4-48" + + cover_id = "cover.rzss" + cover = entity_registry.async_get(cover_id) + assert cover.unique_id == "homekit-00:00:00:00:00:00-5-48" + + sensor_id = "sensor.lr_left_battery" + sensor = entity_registry.async_get(sensor_id) + assert sensor.unique_id == "homekit-00:00:00:00:00:00-2-64" + + sensor_id = "sensor.lr_right_battery" + sensor = entity_registry.async_get(sensor_id) + assert sensor.unique_id == "homekit-00:00:00:00:00:00-3-64" + + sensor_id = "sensor.br_left_battery" + sensor = entity_registry.async_get(sensor_id) + assert sensor.unique_id == "homekit-00:00:00:00:00:00-4-64" + + sensor_id = "sensor.rzss_battery" + sensor = entity_registry.async_get(sensor_id) + assert sensor.unique_id == "homekit-00:00:00:00:00:00-5-64" + + cover_helper = Helper( + hass, + cover_id, + pairing, + accessories[0], + config_entry, + ) + + cover_state = await cover_helper.poll_and_get_state() + assert cover_state.attributes["friendly_name"] == "RZSS" + assert cover_state.state == "open" + + device_registry = dr.async_get(hass) + + device = device_registry.async_get(cover.device_id) + assert device.manufacturer == "RYSE Inc." + assert device.name == "RZSS" + assert device.model == "RYSE Shade" + assert device.sw_version == "3.0.8" + + bridge = device_registry.async_get(device.via_device_id) + assert bridge.manufacturer == "RYSE Inc." + assert bridge.name == "RYSE SmartBridge" + assert bridge.model == "RYSE SmartBridge" + assert bridge.sw_version == "1.3.0" diff --git a/tests/fixtures/homekit_controller/ryse_smart_bridge_four_shades.json b/tests/fixtures/homekit_controller/ryse_smart_bridge_four_shades.json new file mode 100644 index 00000000000..b2e7aabd95d --- /dev/null +++ b/tests/fixtures/homekit_controller/ryse_smart_bridge_four_shades.json @@ -0,0 +1,1066 @@ +[ + { + "aid": 1, + "services": [ + { + "iid": 1, + "type": "0000003E-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 2, + "type": "00000014-0000-1000-8000-0026BB765291", + "format": "bool", + "perms": [ + "pw" + ] + }, + { + "iid": 3, + "type": "00000020-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Inc.", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 4, + "type": "00000021-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE SmartBridge", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 5, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE SmartBridge", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 6, + "type": "00000030-0000-1000-8000-0026BB765291", + "format": "string", + "value": "0401.3521.0679", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 7, + "type": "00000052-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.3.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 8, + "type": "00000053-0000-1000-8000-0026BB765291", + "format": "string", + "value": "0401.3521.0679", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 9, + "type": "34AB8811-AC7F-4340-BAC3-FD6A85F9943B", + "format": "string", + "value": "4.1;3fac0fb4", + "perms": [ + "pr", + "hd" + ], + "ev": false + }, + { + "iid": 10, + "type": "220", + "format": "data", + "value": "Yhl9CmseEb8=", + "perms": [ + "pr", + "hd" + ], + "ev": false, + "maxDataLen": 8 + } + ] + }, + { + "iid": 16, + "type": "000000A2-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 18, + "type": "00000037-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.1.0", + "perms": [ + "pr" + ], + "ev": false + } + ] + } + ] + }, + { + "aid": 2, + "services": [ + { + "iid": 1, + "type": "0000003E-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 2, + "type": "00000014-0000-1000-8000-0026BB765291", + "format": "bool", + "perms": [ + "pw" + ] + }, + { + "iid": 3, + "type": "00000020-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Inc.", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 4, + "type": "00000021-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 5, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "LR Left", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 6, + "type": "00000030-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 7, + "type": "00000052-0000-1000-8000-0026BB765291", + "format": "string", + "value": "3.0.8", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 8, + "type": "00000053-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 11, + "type": "000000A6-0000-1000-8000-0026BB765291", + "format": "uint32", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + } + ] + }, + { + "iid": 48, + "type": "0000008C-0000-1000-8000-0026BB765291", + "primary": true, + "hidden": false, + "linked": [ + 64 + ], + "characteristics": [ + { + "iid": 52, + "type": "0000007C-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "pw", + "ev" + ], + "ev": true, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 53, + "type": "0000006D-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": true, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 54, + "type": "00000072-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 2, + "perms": [ + "pr", + "ev" + ], + "ev": true, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 50, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 55, + "type": "00000024-0000-1000-8000-0026BB765291", + "format": "bool", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": true + } + ] + }, + { + "iid": 64, + "type": "00000096-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 67, + "type": "00000068-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 89, + "perms": [ + "pr", + "ev" + ], + "ev": true, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 68, + "type": "0000008F-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": true, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 70, + "type": "00000079-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": true, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + }, + { + "iid": 66, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + } + ] + } + ] + }, + { + "aid": 3, + "services": [ + { + "iid": 1, + "type": "0000003E-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 2, + "type": "00000014-0000-1000-8000-0026BB765291", + "format": "bool", + "perms": [ + "pw" + ] + }, + { + "iid": 3, + "type": "00000020-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Inc.", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 4, + "type": "00000021-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 5, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "LR Right", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 6, + "type": "00000030-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 7, + "type": "00000052-0000-1000-8000-0026BB765291", + "format": "string", + "value": "3.0.8", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 8, + "type": "00000053-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 11, + "type": "000000A6-0000-1000-8000-0026BB765291", + "format": "uint32", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + } + ] + }, + { + "iid": 48, + "type": "0000008C-0000-1000-8000-0026BB765291", + "primary": true, + "hidden": false, + "linked": [ + 64 + ], + "characteristics": [ + { + "iid": 52, + "type": "0000007C-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "pw", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 53, + "type": "0000006D-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 54, + "type": "00000072-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 2, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 50, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 55, + "type": "00000024-0000-1000-8000-0026BB765291", + "format": "bool", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false + } + ] + }, + { + "iid": 64, + "type": "00000096-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 67, + "type": "00000068-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 100, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 68, + "type": "0000008F-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 2, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 70, + "type": "00000079-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + }, + { + "iid": 66, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + } + ] + } + ] + }, + { + "aid": 4, + "services": [ + { + "iid": 1, + "type": "0000003E-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 2, + "type": "00000014-0000-1000-8000-0026BB765291", + "format": "bool", + "perms": [ + "pw" + ] + }, + { + "iid": 3, + "type": "00000020-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Inc.", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 4, + "type": "00000021-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 5, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "BR Left", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 6, + "type": "00000030-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 7, + "type": "00000052-0000-1000-8000-0026BB765291", + "format": "string", + "value": "3.0.8", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 8, + "type": "00000053-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 11, + "type": "000000A6-0000-1000-8000-0026BB765291", + "format": "uint32", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + } + ] + }, + { + "iid": 48, + "type": "0000008C-0000-1000-8000-0026BB765291", + "primary": true, + "hidden": false, + "linked": [ + 64 + ], + "characteristics": [ + { + "iid": 52, + "type": "0000007C-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 100, + "perms": [ + "pr", + "pw", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 53, + "type": "0000006D-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 100, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 54, + "type": "00000072-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 2, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 50, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 55, + "type": "00000024-0000-1000-8000-0026BB765291", + "format": "bool", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false + } + ] + }, + { + "iid": 64, + "type": "00000096-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 67, + "type": "00000068-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 100, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 68, + "type": "0000008F-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 2, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 70, + "type": "00000079-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + }, + { + "iid": 66, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + } + ] + } + ] + }, + { + "aid": 5, + "services": [ + { + "iid": 1, + "type": "0000003E-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 2, + "type": "00000014-0000-1000-8000-0026BB765291", + "format": "bool", + "perms": [ + "pw" + ] + }, + { + "iid": 3, + "type": "00000020-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Inc.", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 4, + "type": "00000021-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 5, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RZSS", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 6, + "type": "00000030-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 7, + "type": "00000052-0000-1000-8000-0026BB765291", + "format": "string", + "value": "3.0.8", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 8, + "type": "00000053-0000-1000-8000-0026BB765291", + "format": "string", + "value": "1.0.0", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 11, + "type": "000000A6-0000-1000-8000-0026BB765291", + "format": "uint32", + "value": 1, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + } + ] + }, + { + "iid": 48, + "type": "0000008C-0000-1000-8000-0026BB765291", + "primary": true, + "hidden": false, + "linked": [ + 64 + ], + "characteristics": [ + { + "iid": 52, + "type": "0000007C-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 100, + "perms": [ + "pr", + "pw", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 53, + "type": "0000006D-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 100, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 54, + "type": "00000072-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 2, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 50, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + }, + { + "iid": 55, + "type": "00000024-0000-1000-8000-0026BB765291", + "format": "bool", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false + } + ] + }, + { + "iid": 64, + "type": "00000096-0000-1000-8000-0026BB765291", + "primary": false, + "hidden": false, + "linked": [], + "characteristics": [ + { + "iid": 67, + "type": "00000068-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "iid": 68, + "type": "0000008F-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 0, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 2, + "minStep": 1 + }, + { + "iid": 70, + "type": "00000079-0000-1000-8000-0026BB765291", + "format": "uint8", + "value": 1, + "perms": [ + "pr", + "ev" + ], + "ev": false, + "minValue": 0, + "maxValue": 1, + "minStep": 1 + }, + { + "iid": 66, + "type": "00000023-0000-1000-8000-0026BB765291", + "format": "string", + "value": "RYSE Shade", + "perms": [ + "pr" + ], + "ev": false + } + ] + } + ] + } +]