Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
adopt to Availability- and StateEvent (#357)
Browse files Browse the repository at this point in the history
* adopt to Available and StateEvent

* rename AvailableEvent to AvailabilityEvent
  • Loading branch information
edenhaus committed May 30, 2023
1 parent fe3ff20 commit a2cbe27
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions custom_components/deebot/const.py
Expand Up @@ -9,8 +9,8 @@
FanSpeedEvent,
LifeSpanEvent,
RoomsEvent,
StateEvent,
StatsEvent,
StatusEvent,
WaterInfoEvent,
)
from deebot_client.models import VacuumState
Expand Down Expand Up @@ -82,7 +82,7 @@
"Life spans": LifeSpanEvent,
"Rooms": RoomsEvent,
"Stats": StatsEvent,
"Status": StatusEvent,
"Status": StateEvent,
"Water": WaterInfoEvent,
}
REFRESH_MAP = "Map"
Expand Down
6 changes: 3 additions & 3 deletions 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
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion custom_components/deebot/manifest.json
Expand Up @@ -15,7 +15,7 @@
"gmqtt"
],
"requirements": [
"deebot-client==2.0.0b2",
"deebot-client==2.0.0b3",
"numpy>=1.21.2"
],
"version": "v0.0.0"
Expand Down
6 changes: 3 additions & 3 deletions custom_components/deebot/vacuum.py
Expand Up @@ -22,7 +22,7 @@
FanSpeedEvent,
ReportStatsEvent,
RoomsEvent,
StatusEvent,
StateEvent,
)
from deebot_client.events.event_bus import EventListener
from deebot_client.models import Room, VacuumState
Expand Down Expand Up @@ -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()

Expand All @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
1 change: 1 addition & 0 deletions scripts/setup
Expand Up @@ -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

0 comments on commit a2cbe27

Please sign in to comment.