From a2cbe2765642cfeefb9a72ce68e4fff1fd083363 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Tue, 30 May 2023 18:12:58 +0200 Subject: [PATCH] adopt to Availability- and StateEvent (#357) * adopt to Available and StateEvent * rename AvailableEvent to AvailabilityEvent --- custom_components/deebot/const.py | 4 ++-- custom_components/deebot/entity.py | 6 +++--- custom_components/deebot/manifest.json | 2 +- custom_components/deebot/vacuum.py | 6 +++--- requirements.txt | 2 +- scripts/setup | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/custom_components/deebot/const.py b/custom_components/deebot/const.py index eda2915..17f0a90 100644 --- a/custom_components/deebot/const.py +++ b/custom_components/deebot/const.py @@ -9,8 +9,8 @@ FanSpeedEvent, LifeSpanEvent, RoomsEvent, + StateEvent, StatsEvent, - StatusEvent, WaterInfoEvent, ) from deebot_client.models import VacuumState @@ -82,7 +82,7 @@ "Life spans": LifeSpanEvent, "Rooms": RoomsEvent, "Stats": StatsEvent, - "Status": StatusEvent, + "Status": StateEvent, "Water": WaterInfoEvent, } REFRESH_MAP = "Map" diff --git a/custom_components/deebot/entity.py b/custom_components/deebot/entity.py index 1de4018..20144b4 100644 --- a/custom_components/deebot/entity.py +++ b/custom_components/deebot/entity.py @@ -1,5 +1,5 @@ """Deebot entity module.""" -from deebot_client.events import StatusEvent +from deebot_client.events import AvailabilityEvent from deebot_client.events.event_bus import EventListener from deebot_client.vacuum_bot import VacuumBot from homeassistant.helpers.entity import DeviceInfo, Entity, EntityDescription @@ -68,11 +68,11 @@ async def async_added_to_hass(self) -> None: if not self._always_available: - async def on_status(event: StatusEvent) -> None: + async def on_available(event: AvailabilityEvent) -> None: self._attr_available = event.available self.async_write_ha_state() listener: EventListener = self._vacuum_bot.events.subscribe( - StatusEvent, on_status + AvailabilityEvent, on_available ) self.async_on_remove(listener.unsubscribe) diff --git a/custom_components/deebot/manifest.json b/custom_components/deebot/manifest.json index 7438e7b..0b045e9 100644 --- a/custom_components/deebot/manifest.json +++ b/custom_components/deebot/manifest.json @@ -15,7 +15,7 @@ "gmqtt" ], "requirements": [ - "deebot-client==2.0.0b2", + "deebot-client==2.0.0b3", "numpy>=1.21.2" ], "version": "v0.0.0" diff --git a/custom_components/deebot/vacuum.py b/custom_components/deebot/vacuum.py index 99bedc2..87b9cb8 100644 --- a/custom_components/deebot/vacuum.py +++ b/custom_components/deebot/vacuum.py @@ -22,7 +22,7 @@ FanSpeedEvent, ReportStatsEvent, RoomsEvent, - StatusEvent, + StateEvent, ) from deebot_client.events.event_bus import EventListener from deebot_client.models import Room, VacuumState @@ -141,7 +141,7 @@ async def on_rooms(event: RoomsEvent) -> None: self._rooms = event.rooms self.async_write_ha_state() - async def on_status(event: StatusEvent) -> None: + async def on_status(event: StateEvent) -> None: self._state = event.state self.async_write_ha_state() @@ -152,7 +152,7 @@ async def on_status(event: StatusEvent) -> None: self._vacuum_bot.events.subscribe(FanSpeedEvent, on_fan_speed), self._vacuum_bot.events.subscribe(ReportStatsEvent, on_report_stats), self._vacuum_bot.events.subscribe(RoomsEvent, on_rooms), - self._vacuum_bot.events.subscribe(StatusEvent, on_status), + self._vacuum_bot.events.subscribe(StateEvent, on_status), ] self.async_on_remove(lambda: unsubscribe_listeners(listeners)) diff --git a/requirements.txt b/requirements.txt index 8b9edb3..af308ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # if code from specific branch is needed #git+https://github.com/DeebotUniverse/client.py@available_check#deebot-client==2.0.0b2 -deebot-client==2.0.0b2 +deebot-client==2.0.0b3 homeassistant>=2022.10.0b0 mypy==1.3.0 diff --git a/scripts/setup b/scripts/setup index 2f17431..e45cd21 100755 --- a/scripts/setup +++ b/scripts/setup @@ -7,3 +7,4 @@ cd "$(dirname "$0")/.." scripts/install/pip_packages "pip" scripts/install/pip_packages setuptools wheel scripts/install/pip_packages --requirement requirements.txt +pre-commit install