Skip to content

Commit

Permalink
Bump deebot-client to 7.0.0 (home-assistant#116025)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus authored Apr 23, 2024
1 parent 2977ec4 commit fd14695
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
6 changes: 2 additions & 4 deletions homeassistant/components/ecovacs/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .const import DOMAIN
from .controller import EcovacsController
from .entity import EcovacsEntity
from .util import get_name_key


async def async_setup_entry(
Expand Down Expand Up @@ -54,10 +55,7 @@ async def on_event(event: ReportStatsEvent) -> None:
# we trigger only on job done
return

event_type = event.status.name.lower()
if event.status == CleanJobStatus.MANUAL_STOPPED:
event_type = "manually_stopped"

event_type = get_name_key(event.status)
self._trigger_event(event_type)
self.async_write_ha_state()

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ecovacs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/ecovacs",
"iot_class": "cloud_push",
"loggers": ["sleekxmppfs", "sucks", "deebot_client"],
"requirements": ["py-sucks==0.9.9", "deebot-client==6.0.2"]
"requirements": ["py-sucks==0.9.9", "deebot-client==7.0.0"]
}
10 changes: 5 additions & 5 deletions homeassistant/components/ecovacs/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
EcovacsDescriptionEntity,
EventT,
)
from .util import get_supported_entitites
from .util import get_name_key, get_supported_entitites


@dataclass(kw_only=True, frozen=True)
Expand All @@ -41,17 +41,17 @@ class EcovacsSelectEntityDescription(
EcovacsSelectEntityDescription[WaterInfoEvent](
device_capabilities=VacuumCapabilities,
capability_fn=lambda caps: caps.water,
current_option_fn=lambda e: e.amount.display_name,
options_fn=lambda water: [amount.display_name for amount in water.types],
current_option_fn=lambda e: get_name_key(e.amount),
options_fn=lambda water: [get_name_key(amount) for amount in water.types],
key="water_amount",
translation_key="water_amount",
entity_category=EntityCategory.CONFIG,
),
EcovacsSelectEntityDescription[WorkModeEvent](
device_capabilities=VacuumCapabilities,
capability_fn=lambda caps: caps.clean.work_mode,
current_option_fn=lambda e: e.mode.display_name,
options_fn=lambda cap: [mode.display_name for mode in cap.types],
current_option_fn=lambda e: get_name_key(e.mode),
options_fn=lambda cap: [get_name_key(mode) for mode in cap.types],
key="work_mode",
translation_key="work_mode",
entity_registry_enabled_default=False,
Expand Down
9 changes: 9 additions & 0 deletions homeassistant/components/ecovacs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

from __future__ import annotations

from enum import Enum
import random
import string
from typing import TYPE_CHECKING

from deebot_client.capabilities import Capabilities

from homeassistant.core import callback

from .entity import (
EcovacsCapabilityEntityDescription,
EcovacsDescriptionEntity,
Expand Down Expand Up @@ -38,3 +41,9 @@ def get_supported_entitites(
if isinstance(device.capabilities, description.device_capabilities)
if (capability := description.capability_fn(device.capabilities))
]


@callback
def get_name_key(enum: Enum) -> str:
"""Return the lower case name of the enum."""
return enum.name.lower()
5 changes: 3 additions & 2 deletions homeassistant/components/ecovacs/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .const import DOMAIN
from .controller import EcovacsController
from .entity import EcovacsEntity
from .util import get_name_key

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -242,7 +243,7 @@ def __init__(self, device: Device[VacuumCapabilities]) -> None:
self._rooms: list[Room] = []

self._attr_fan_speed_list = [
level.display_name for level in capabilities.fan_speed.types
get_name_key(level) for level in capabilities.fan_speed.types
]

async def async_added_to_hass(self) -> None:
Expand All @@ -254,7 +255,7 @@ async def on_battery(event: BatteryEvent) -> None:
self.async_write_ha_state()

async def on_fan_speed(event: FanSpeedEvent) -> None:
self._attr_fan_speed = event.speed.display_name
self._attr_fan_speed = get_name_key(event.speed)
self.async_write_ha_state()

async def on_rooms(event: RoomsEvent) -> None:
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ debugpy==1.8.1
# decora==0.6

# homeassistant.components.ecovacs
deebot-client==6.0.2
deebot-client==7.0.0

# homeassistant.components.ihc
# homeassistant.components.namecheapdns
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ dbus-fast==2.21.1
debugpy==1.8.1

# homeassistant.components.ecovacs
deebot-client==6.0.2
deebot-client==7.0.0

# homeassistant.components.ihc
# homeassistant.components.namecheapdns
Expand Down
2 changes: 1 addition & 1 deletion tests/components/ecovacs/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def test_last_job(
await notify_and_wait(
hass,
event_bus,
ReportStatsEvent(0, 1, "spotArea", "3", CleanJobStatus.MANUAL_STOPPED, [1]),
ReportStatsEvent(0, 1, "spotArea", "3", CleanJobStatus.MANUALLY_STOPPED, [1]),
)

assert (state := hass.states.get(state.entity_id))
Expand Down

0 comments on commit fd14695

Please sign in to comment.