diff --git a/custom_components/deebot/const.py b/custom_components/deebot/const.py index 806b4b8..8af0714 100644 --- a/custom_components/deebot/const.py +++ b/custom_components/deebot/const.py @@ -27,7 +27,7 @@ ################################ # Do not change! Will be set by release workflow INTEGRATION_VERSION = "main" # git tag will be used -MIN_REQUIRED_HA_VERSION = "2022.5.0b0" # set min required version in hacs.json +MIN_REQUIRED_HA_VERSION = "2022.7.0b0" # set min required version in hacs.json ################################ # Values below can be changed diff --git a/custom_components/deebot/number.py b/custom_components/deebot/number.py index 5a1dd7f..0c376f3 100644 --- a/custom_components/deebot/number.py +++ b/custom_components/deebot/number.py @@ -1,5 +1,4 @@ """Number module.""" -import logging from typing import Optional from deebot_client.commands import SetVolume @@ -16,8 +15,6 @@ from .entity import DeebotEntity from .hub import DeebotHub -_LOGGER = logging.getLogger(__name__) - async def async_setup_entry( hass: HomeAssistant, @@ -44,10 +41,10 @@ class VolumeEntity(DeebotEntity, NumberEntity): # type: ignore entity_category=EntityCategory.CONFIG, ) - _attr_min_value = 0 - _attr_max_value = 10 - _attr_step = 1.0 - _attr_value = None + _attr_native_min_value = 0 + _attr_native_max_value = 10 + _attr_native_step = 1.0 + _attr_native_value: float | None = None async def async_added_to_hass(self) -> None: """Set up the event listeners now that hass is ready.""" @@ -55,8 +52,8 @@ async def async_added_to_hass(self) -> None: async def on_volume(event: VolumeEvent) -> None: if event.maximum is not None: - self._attr_max_value = event.maximum - self._attr_value = event.volume + self._attr_native_max_value = event.maximum + self._attr_native_value = event.volume self.async_write_ha_state() listener: EventListener = self._vacuum_bot.events.subscribe( @@ -67,21 +64,22 @@ async def on_volume(event: VolumeEvent) -> None: @property def icon(self) -> Optional[str]: """Return the icon to use in the frontend, if any.""" - if self._attr_value is not None: + if self._attr_native_value is not None: arrays = array_split( - range(self._attr_min_value + 1, self._attr_max_value + 1), 3 + range(self._attr_native_min_value + 1, self._attr_native_max_value + 1), + 3, ) - if self._attr_value == self._attr_min_value: + if self._attr_native_value == self._attr_native_min_value: return "mdi:volume-off" - if self._attr_value in arrays[0]: + if self._attr_native_value in arrays[0]: return "mdi:volume-low" - if self._attr_value in arrays[1]: + if self._attr_native_value in arrays[1]: return "mdi:volume-medium" - if self._attr_value in arrays[2]: + if self._attr_native_value in arrays[2]: return "mdi:volume-high" return "mdi:volume-medium" - async def async_set_value(self, value: float) -> None: + async def async_set_native_value(self, value: float) -> None: """Set new value.""" await self._vacuum_bot.execute_command(SetVolume(int(value))) diff --git a/hacs.json b/hacs.json index 0e60fa4..f0f002c 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,6 @@ { "filename": "deebot.zip", - "homeassistant": "2022.5.0b0", + "homeassistant": "2022.7.0b0", "name": "Deebot 4 Home Assistant", "render_readme": true, "zip_release": true diff --git a/requirements.txt b/requirements.txt index 3656103..38a1f5a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # git+https://github.com/DeebotUniverse/client.py@main#deebot-client==0.0.1b1 deebot-client==1.4.1 -homeassistant>=2022.5.0.b0 +homeassistant>=2022.7.0.b0 mypy==0.961 numpy>=1.21.2