Skip to content

Commit

Permalink
Upgrade to required Hass version 2024.1 (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekman authored Nov 13, 2024
1 parent 4a77888 commit 0d3d664
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ commands:
jobs:
lint:
docker:
- image: cimg/python:3.9
- image: cimg/python:3.11
resource_class: small
steps:
- checkout
Expand All @@ -27,7 +27,7 @@ jobs:
- run: find . -name "*.json" -type f -print0 | xargs -0I {} python3 -m json.tool {}
test:
docker:
- image: cimg/python:3.9
- image: cimg/python:3.11
resource_class: small
steps:
- checkout
Expand Down
4 changes: 2 additions & 2 deletions custom_components/purei9/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Coordinate data updates from Pure i9."""
import logging
from datetime import timedelta
import async_timeout
from asyncio import timeout
from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
UpdateFailed,
Expand Down Expand Up @@ -31,7 +31,7 @@ def robot(self) -> str:
async def _async_update_data(self):
"""Fetch data from Pure i9."""
try:
async with async_timeout.timeout(10):
async with timeout(10):
return await self.hass.async_add_executor_job(
self.update_and_create_params
)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/purei9/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"codeowners": ["Ekman"],
"requirements": ["purei9_unofficial==0.0.14"],
"iot_class": "cloud_polling",
"config_flow": true
"config_flow": true,
"homeassistant": "2024.1.0"
}
35 changes: 33 additions & 2 deletions custom_components/purei9/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
STATE_IDLE
)
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.const import CONF_PASSWORD, CONF_EMAIL
from homeassistant.const import CONF_PASSWORD, CONF_EMAIL, CONF_COUNTRY_CODE
from purei9_unofficial.cloudv3 import CloudRobot
from . import purei9, const, vacuum_command, exception, utility

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_EMAIL): str,
vol.Required(CONF_PASSWORD): str
vol.Required(CONF_PASSWORD): str,
vol.Required(CONF_COUNTRY_CODE): str
})

async def async_setup_entry(hass, config_entry, async_add_entities):
Expand All @@ -39,6 +40,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
[PureI9(coord, coord.robot, coord.data) for coord in data[const.COORDINATORS]]
)

# pylint: disable=R0904
class PureI9(CoordinatorEntity, StateVacuumEntity):
"""The main Pure i9 vacuum entity"""
def __init__(
Expand Down Expand Up @@ -149,18 +151,27 @@ async def async_start(self):
self._params.state = STATE_CLEANING
self.async_write_ha_state()

def start(self):
raise NotImplementedError

async def async_return_to_base(self, **kwargs):
"""Return to the dock"""
await self.hass.async_add_executor_job(self._robot.gohome)
self._params.state = STATE_RETURNING
self.async_write_ha_state()

def return_to_base(self, **kwargs):
raise NotImplementedError

async def async_stop(self, **kwargs):
"""Stop cleaning"""
await self.hass.async_add_executor_job(self._robot.stopclean)
self._params.state = STATE_IDLE
self.async_write_ha_state()

def stop(self, **kwargs):
raise NotImplementedError

async def async_pause(self):
"""Pause cleaning"""
# According to Home Assistant, pause should be an idempotent
Expand All @@ -171,6 +182,9 @@ async def async_pause(self):
self._params.state = STATE_PAUSED
self.async_write_ha_state()

def pause(self):
raise NotImplementedError

async def async_set_fan_speed(self, fan_speed: str, **kwargs: Any):
"""Set the fan speed of the robot"""
await self.hass.async_add_executor_job(
Expand All @@ -180,6 +194,9 @@ async def async_set_fan_speed(self, fan_speed: str, **kwargs: Any):
self._params.fan_speed = fan_speed
self.async_write_ha_state()

def set_fan_speed(self, fan_speed, **kwargs):
raise NotImplementedError

async def async_send_command(
self,
command: str,
Expand Down Expand Up @@ -207,6 +224,14 @@ async def async_send_command(
except exception.CommandException as ex:
_LOGGER.error("Could not execute command \"%s\" due to: %s", command, ex)

def send_command(
self,
command: str,
params: dict[str, Any] | list[Any] | None = None,
**kwargs: Any,
):
raise NotImplementedError

def _handle_coordinator_update(self):
"""
Called by Home Assistant asking the vacuum to update to the latest state.
Expand All @@ -225,3 +250,9 @@ def _handle_coordinator_update(self):
self._params.maps = params.maps

self.async_write_ha_state()

def locate(self, **kwargs):
raise NotImplementedError

def clean_spot(self, **kwargs):
raise NotImplementedError
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
purei9_unofficial==0.0.14
homeassistant==2021.11.5
homeassistant==2024.1.0
pylint==3.3.1

0 comments on commit 0d3d664

Please sign in to comment.