diff --git a/homeassistant/components/insteon/api/aldb.py b/homeassistant/components/insteon/api/aldb.py index 77ece2709d8..663dcf4dffd 100644 --- a/homeassistant/components/insteon/api/aldb.py +++ b/homeassistant/components/insteon/api/aldb.py @@ -4,12 +4,6 @@ from typing import Any from pyinsteon import devices from pyinsteon.constants import ALDBStatus -from pyinsteon.topics import ( - ALDB_STATUS_CHANGED, - DEVICE_LINK_CONTROLLER_CREATED, - DEVICE_LINK_RESPONDER_CREATED, -) -from pyinsteon.utils import subscribe_topic, unsubscribe_topic import voluptuous as vol from homeassistant.components import websocket_api @@ -271,33 +265,31 @@ async def websocket_notify_on_aldb_status( return @callback - def record_added(controller, responder, group): + def record_added(record, sender, deleted): """Forward ALDB events to websocket.""" forward_data = {"type": "record_loaded"} connection.send_message(websocket_api.event_message(msg["id"], forward_data)) @callback - def aldb_loaded(): + def aldb_loaded(status): """Forward ALDB loaded event to websocket.""" forward_data = { "type": "status_changed", - "is_loading": device.aldb.status == ALDBStatus.LOADING, + "is_loading": status == ALDBStatus.LOADING, } connection.send_message(websocket_api.event_message(msg["id"], forward_data)) @callback def async_cleanup() -> None: """Remove signal listeners.""" - unsubscribe_topic(record_added, f"{DEVICE_LINK_CONTROLLER_CREATED}.{device.id}") - unsubscribe_topic(record_added, f"{DEVICE_LINK_RESPONDER_CREATED}.{device.id}") - unsubscribe_topic(aldb_loaded, f"{device.id}.{ALDB_STATUS_CHANGED}") + device.aldb.unsubscribe_record_changed(record_added) + device.aldb.unsubscribe_status_changed(aldb_loaded) forward_data = {"type": "unsubscribed"} connection.send_message(websocket_api.event_message(msg["id"], forward_data)) connection.subscriptions[msg["id"]] = async_cleanup - subscribe_topic(record_added, f"{DEVICE_LINK_CONTROLLER_CREATED}.{device.id}") - subscribe_topic(record_added, f"{DEVICE_LINK_RESPONDER_CREATED}.{device.id}") - subscribe_topic(aldb_loaded, f"{device.id}.{ALDB_STATUS_CHANGED}") + device.aldb.subscribe_record_changed(record_added) + device.aldb.subscribe_status_changed(aldb_loaded) connection.send_result(msg[ID]) diff --git a/homeassistant/components/insteon/ipdb.py b/homeassistant/components/insteon/ipdb.py index 7f4ff92380f..46302d3e6ad 100644 --- a/homeassistant/components/insteon/ipdb.py +++ b/homeassistant/components/insteon/ipdb.py @@ -1,5 +1,5 @@ """Utility methods for the Insteon platform.""" -from pyinsteon.device_types import ( +from pyinsteon.device_types.ipdb import ( AccessControl_Morningstar, ClimateControl_Thermostat, ClimateControl_WirelessThermostat, diff --git a/homeassistant/components/insteon/manifest.json b/homeassistant/components/insteon/manifest.json index 8ff828c7c43..60933962cc0 100644 --- a/homeassistant/components/insteon/manifest.json +++ b/homeassistant/components/insteon/manifest.json @@ -17,7 +17,7 @@ "iot_class": "local_push", "loggers": ["pyinsteon", "pypubsub"], "requirements": [ - "pyinsteon==1.2.0", + "pyinsteon==1.3.1", "insteon-frontend-home-assistant==0.2.0" ], "usb": [ diff --git a/requirements_all.txt b/requirements_all.txt index 463f2af654d..ab5922d24dd 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1684,7 +1684,7 @@ pyialarm==2.2.0 pyicloud==1.0.0 # homeassistant.components.insteon -pyinsteon==1.2.0 +pyinsteon==1.3.1 # homeassistant.components.intesishome pyintesishome==1.8.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 38038be2c4f..dbcfb1cb4a9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1209,7 +1209,7 @@ pyialarm==2.2.0 pyicloud==1.0.0 # homeassistant.components.insteon -pyinsteon==1.2.0 +pyinsteon==1.3.1 # homeassistant.components.ipma pyipma==3.0.5 diff --git a/tests/components/insteon/mock_devices.py b/tests/components/insteon/mock_devices.py index 417769d6696..e1f36ab6411 100644 --- a/tests/components/insteon/mock_devices.py +++ b/tests/components/insteon/mock_devices.py @@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock, patch from pyinsteon.address import Address from pyinsteon.constants import ALDBStatus, ResponseStatus -from pyinsteon.device_types import ( +from pyinsteon.device_types.ipdb import ( AccessControl_Morningstar, DimmableLightingControl_KeypadLinc_8, GeneralController_RemoteLinc, diff --git a/tests/components/insteon/test_api_aldb.py b/tests/components/insteon/test_api_aldb.py index d360b34d7b9..6755a5d9386 100644 --- a/tests/components/insteon/test_api_aldb.py +++ b/tests/components/insteon/test_api_aldb.py @@ -5,7 +5,8 @@ from unittest.mock import patch from pyinsteon import pub from pyinsteon.address import Address -from pyinsteon.topics import ALDB_STATUS_CHANGED, DEVICE_LINK_CONTROLLER_CREATED +from pyinsteon.constants import ALDBStatus +from pyinsteon.topics import ALDB_LINK_CHANGED, ALDB_STATUS_CHANGED import pytest from homeassistant.components import insteon @@ -223,7 +224,7 @@ async def test_notify_on_aldb_status(hass, hass_ws_client, aldb_data): msg = await ws_client.receive_json() assert msg["success"] - pub.sendMessage(f"333333.{ALDB_STATUS_CHANGED}") + pub.sendMessage(f"333333.{ALDB_STATUS_CHANGED}", status=ALDBStatus.LOADED) msg = await ws_client.receive_json() assert msg["event"]["type"] == "status_changed" assert not msg["event"]["is_loading"] @@ -245,10 +246,10 @@ async def test_notify_on_aldb_record_added(hass, hass_ws_client, aldb_data): assert msg["success"] pub.sendMessage( - f"{DEVICE_LINK_CONTROLLER_CREATED}.333333", - controller=Address("11.11.11"), - responder=Address("33.33.33"), - group=100, + f"333333.{ALDB_LINK_CHANGED}", + record="some record", + sender=Address("11.11.11"), + deleted=False, ) msg = await ws_client.receive_json() assert msg["event"]["type"] == "record_loaded"