Skip to content

Commit

Permalink
Update purei9_unofficial and add country code config (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Philipp Jeitner <3951813+Phype@users.noreply.github.com>
  • Loading branch information
Ekman and Phype authored Nov 13, 2024
1 parent 0d3d664 commit fe14573
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
5 changes: 3 additions & 2 deletions custom_components/purei9/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions custom_components/purei9/config_flow.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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(
Expand All @@ -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)
2 changes: 1 addition & 1 deletion custom_components/purei9/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 21 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@ version: "3"
services:
# localhost:8123
hass:
image: homeassistant/home-assistant:stable
image: homeassistant/home-assistant:2024.1.0
restart: unless-stopped
volumes:
- ./hass:/config
- ./custom_components:/config/custom_components:ro
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
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
purei9_unofficial==0.0.16
homeassistant==2024.1.0
pylint==3.3.1

0 comments on commit fe14573

Please sign in to comment.