Update zwave-me-ws version to 0.3.6 (#90233)

pull/90415/head
Dmitry Vlasov 2023-03-28 18:24:19 +03:00 committed by GitHub
parent 9fecdddf01
commit 4b3c1f2800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 4 deletions

View File

@ -50,6 +50,8 @@ class ZWaveMeController:
self.zwave_api = ZWaveMe(
on_device_create=self.on_device_create,
on_device_update=self.on_device_update,
on_device_remove=self.on_device_unavailable,
on_device_destroy=self.on_device_destroy,
on_new_device=self.add_device,
token=self.config.data[CONF_TOKEN],
url=self.config.data[CONF_URL],
@ -82,6 +84,14 @@ class ZWaveMeController:
"""Send signal to update device."""
dispatcher_send(self._hass, f"ZWAVE_ME_INFO_{new_info.id}", new_info)
def on_device_unavailable(self, device_id: str) -> None:
"""Send signal to set device unavailable."""
dispatcher_send(self._hass, f"ZWAVE_ME_UNAVAILABLE_{device_id}")
def on_device_destroy(self, device_id: str) -> None:
"""Send signal to destroy device."""
dispatcher_send(self._hass, f"ZWAVE_ME_DESTROY_{device_id}")
def remove_stale_devices(self, registry: dr.DeviceRegistry):
"""Remove old-format devices in the registry."""
for device_id in self.device_ids:
@ -133,10 +143,33 @@ class ZWaveMeEntity(Entity):
self.hass, f"ZWAVE_ME_INFO_{self.device.id}", self.get_new_data
)
)
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"ZWAVE_ME_UNAVAILABLE_{self.device.id}",
self.set_unavailable_status,
)
)
self.async_on_remove(
async_dispatcher_connect(
self.hass, f"ZWAVE_ME_DESTROY_{self.device.id}", self.delete_entity
)
)
@callback
def get_new_data(self, new_data):
def get_new_data(self, new_data: ZWaveMeData) -> None:
"""Update info in the HAss."""
self.device = new_data
self._attr_available = not new_data.isFailed
self.async_write_ha_state()
@callback
def set_unavailable_status(self):
"""Update status in the HAss."""
self._attr_available = False
self.async_write_ha_state()
@callback
def delete_entity(self) -> None:
"""Remove this entity."""
self.hass.async_create_task(self.async_remove(force_remove=True))

View File

@ -6,7 +6,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/zwave_me",
"iot_class": "local_push",
"requirements": ["zwave_me_ws==0.3.1", "url-normalize==1.4.3"],
"requirements": ["zwave_me_ws==0.3.6", "url-normalize==1.4.3"],
"zeroconf": [
{
"type": "_hap._tcp.local.",

View File

@ -2731,4 +2731,4 @@ zm-py==0.5.2
zwave-js-server-python==0.47.0
# homeassistant.components.zwave_me
zwave_me_ws==0.3.1
zwave_me_ws==0.3.6

View File

@ -1956,4 +1956,4 @@ zigpy==0.53.2
zwave-js-server-python==0.47.0
# homeassistant.components.zwave_me
zwave_me_ws==0.3.1
zwave_me_ws==0.3.6