From fe1457352d80e044bbe359d2a0d23118cc665df9 Mon Sep 17 00:00:00 2001 From: Niklas Ekman Date: Wed, 13 Nov 2024 18:59:33 +0100 Subject: [PATCH] Update purei9_unofficial and add country code config (#76) Co-authored-by: Philipp Jeitner <3951813+Phype@users.noreply.github.com> --- custom_components/purei9/__init__.py | 5 +++-- custom_components/purei9/config_flow.py | 8 +++++--- custom_components/purei9/manifest.json | 2 +- docker-compose.yml | 22 +++++++++++++++++++++- requirements.txt | 2 +- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/custom_components/purei9/__init__.py b/custom_components/purei9/__init__.py index 690587c..03e02a7 100644 --- a/custom_components/purei9/__init__.py +++ b/custom_components/purei9/__init__.py @@ -1,6 +1,6 @@ """Control your Electrolux Purei9 vacuum robot""" import asyncio -from homeassistant.const import CONF_PASSWORD, CONF_EMAIL +from homeassistant.const import CONF_PASSWORD, CONF_EMAIL, CONF_COUNTRY_CODE from purei9_unofficial.cloudv3 import CloudClient from . import const, coordinator @@ -10,8 +10,9 @@ async def async_setup_entry(hass, config_entry) -> bool: """Setup the integration after the config flow""" email = config_entry.data.get(CONF_EMAIL) password = config_entry.data.get(CONF_PASSWORD) + countrycode = config_entry.data.get(CONF_COUNTRY_CODE) - purei9_client = CloudClient(email, password) + purei9_client = CloudClient(email, password, countrycode=countrycode) robots = await hass.async_add_executor_job(purei9_client.getRobots) robots = list(robots) diff --git a/custom_components/purei9/config_flow.py b/custom_components/purei9/config_flow.py index 2b405f4..d1c6a3e 100644 --- a/custom_components/purei9/config_flow.py +++ b/custom_components/purei9/config_flow.py @@ -1,7 +1,7 @@ """Initial user configuration for the integration""" import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import CONF_EMAIL, CONF_PASSWORD +from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_COUNTRY_CODE from purei9_unofficial.cloudv3 import CloudClient from .const import DOMAIN @@ -17,8 +17,9 @@ async def async_step_user(self, user_input=None): # Validate that the provided credentials are correct email = user_input[CONF_EMAIL] password = user_input[CONF_PASSWORD] + countrycode = user_input[CONF_COUNTRY_CODE] - purei9_client = CloudClient(email, password) + purei9_client = CloudClient(email, password, countrycode=countrycode) await self.hass.async_add_executor_job(purei9_client.tryLogin) return self.async_create_entry( @@ -31,7 +32,8 @@ async def async_step_user(self, user_input=None): schema = vol.Schema({ vol.Required(CONF_EMAIL): str, - vol.Required(CONF_PASSWORD): str + vol.Required(CONF_PASSWORD): str, + vol.Required(CONF_COUNTRY_CODE): str, }) return self.async_show_form(step_id="user", data_schema=schema, errors=errors) diff --git a/custom_components/purei9/manifest.json b/custom_components/purei9/manifest.json index 1e2b427..907d382 100644 --- a/custom_components/purei9/manifest.json +++ b/custom_components/purei9/manifest.json @@ -6,7 +6,7 @@ "issue_tracker": "https://github.com/Ekman/home-assistant-pure-i9/issues", "dependencies": [], "codeowners": ["Ekman"], - "requirements": ["purei9_unofficial==0.0.14"], + "requirements": ["purei9_unofficial==0.0.16"], "iot_class": "cloud_polling", "config_flow": true, "homeassistant": "2024.1.0" diff --git a/docker-compose.yml b/docker-compose.yml index 91f53f2..1754f80 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: # localhost:8123 hass: - image: homeassistant/home-assistant:stable + image: homeassistant/home-assistant:2024.1.0 restart: unless-stopped volumes: - ./hass:/config @@ -10,3 +10,23 @@ services: environment: TZ: Europe/Stockholm ports: [ "8123:8123" ] + lint: + image: cimg/python:3.11 + volumes: [ "./:/files:ro" ] + working_dir: /files + entrypoint: [ pylint ] + command: + - custom_components/purei9 + - tests + test: + image: cimg/python:3.11 + volumes: [ "./:/files:ro" ] + working_dir: /files + entrypoint: [ python3 ] + command: + - -m + - unittest + - discover + - --start-directory + - tests + - --verbose diff --git a/requirements.txt b/requirements.txt index ccc3a85..1685fae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -purei9_unofficial==0.0.14 +purei9_unofficial==0.0.16 homeassistant==2024.1.0 pylint==3.3.1