Bump pyinsteon to 1.3.1 (#87788)

* Bump pyinsteon to 1.3.1

* Fix record received test

* Fix status received test
This commit is contained in:
Tom Harris 2023-02-09 15:40:06 -05:00 committed by GitHub
parent 8fddd0e53a
commit 926534bde2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 26 deletions

View File

@ -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])

View File

@ -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,

View File

@ -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": [

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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"