Add wired devices to Homematic IP Cloud (#41232)

* Add wired devices to HomematicIP Cloud

* Add test to check device registry

* Add comments

* Update comment
This commit is contained in:
SukramJ authored and GitHub committed 2020-10-23 21:14:54 -05:00
1 parent ea0e359d90
commit 6efb782871
6 files changed
+206 -24

No files matched your search

@@ -540,3 +540,28 @@ async def test_hmip_security_sensor_group(hass, default_mock_hap_factory):
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
async def test_hmip_wired_multi_contact_interface(hass, default_mock_hap_factory):
"""Test HomematicipMultiContactInterface."""
entity_id = "binary_sensor.wired_eingangsmodul_32_fach_channel5"
entity_name = "Wired Eingangsmodul – 32-fach Channel5"
device_model = "HmIPW-DRI32"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wired Eingangsmodul – 32-fach"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_OFF
await async_manipulate_test_data(
hass, hmip_device, "windowState", WindowState.OPEN, channel=5
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON
await async_manipulate_test_data(hass, hmip_device, "windowState", None, channel=5)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
@@ -22,7 +22,7 @@ async def test_hmip_load_all_supported_devices(hass, default_mock_hap_factory):
test_devices=None, test_groups=None
)
assert len(mock_hap.hmip_device_by_entity_id) == 192
assert len(mock_hap.hmip_device_by_entity_id) == 231
async def test_hmip_remove_device(hass, default_mock_hap_factory):
@@ -240,3 +240,36 @@ async def test_hmip_reset_energy_counter_services(hass, default_mock_hap_factory
)
assert hmip_device.mock_calls[-1][0] == "reset_energy_counter"
assert len(hmip_device._connection.mock_calls) == 4 # pylint: disable=W0212
async def test_hmip_multi_area_device(hass, default_mock_hap_factory):
"""Test multi area device. Check if devices are created and referenced."""
entity_id = "binary_sensor.wired_eingangsmodul_32_fach_channel5"
entity_name = "Wired Eingangsmodul – 32-fach Channel5"
device_model = "HmIPW-DRI32"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wired Eingangsmodul – 32-fach"]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state
# get the entity
entity_registry = await er.async_get_registry(hass)
entity = entity_registry.async_get(ha_state.entity_id)
assert entity
# get the device
device_registry = await dr.async_get_registry(hass)
device = device_registry.async_get(entity.device_id)
assert device.name == entity_name
# get the base device
via_device = device_registry.async_get(device.via_device_id)
assert via_device.name == "Wired Eingangsmodul – 32-fach"
# get the hap
hap_device = device_registry.async_get(via_device.via_device_id)
assert hap_device.name == "Access Point"
@@ -220,3 +220,42 @@ async def test_hmip_multi_switch(hass, default_mock_hap_factory):
await async_manipulate_test_data(hass, hmip_device, "on", False)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
async def test_hmip_wired_multi_switch(hass, default_mock_hap_factory):
"""Test HomematicipMultiSwitch."""
entity_id = "switch.fernseher_wohnzimmer"
entity_name = "Fernseher (Wohnzimmer)"
device_model = "HmIPW-DRS8"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[
"Wired Schaltaktor – 8-fach",
]
)
ha_state, hmip_device = get_and_check_entity_basics(
hass, mock_hap, entity_id, entity_name, device_model
)
assert ha_state.state == STATE_ON
service_call_counter = len(hmip_device.mock_calls)
await hass.services.async_call(
"switch", "turn_off", {"entity_id": entity_id}, blocking=True
)
assert len(hmip_device.mock_calls) == service_call_counter + 1
assert hmip_device.mock_calls[-1][0] == "turn_off"
assert hmip_device.mock_calls[-1][1] == (1,)
await async_manipulate_test_data(hass, hmip_device, "on", False)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OFF
await hass.services.async_call(
"switch", "turn_on", {"entity_id": entity_id}, blocking=True
)
assert len(hmip_device.mock_calls) == service_call_counter + 3
assert hmip_device.mock_calls[-1][0] == "turn_on"
assert hmip_device.mock_calls[-1][1] == (1,)
await async_manipulate_test_data(hass, hmip_device, "on", True)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_ON