diff --git a/custom_components/xplora_watch/config_flow.py b/custom_components/xplora_watch/config_flow.py index 414a2ac..cbbd2ec 100644 --- a/custom_components/xplora_watch/config_flow.py +++ b/custom_components/xplora_watch/config_flow.py @@ -7,12 +7,8 @@ from types import MappingProxyType from typing import Any -import voluptuous as vol -from pyxplora_api.exception_classes import Error, LoginError, PhoneOrEmailFail -from pyxplora_api.pyxplora_api_async import PyXploraApi -from pyxplora_api.status import UserContactType - import homeassistant.helpers.config_validation as cv +import voluptuous as vol from homeassistant import config_entries, core from homeassistant.config_entries import ( ConfigEntry, @@ -46,6 +42,9 @@ TextSelectorConfig, TextSelectorType, ) +from pyxplora_api.exception_classes import Error, LoginError, PhoneOrEmailFail +from pyxplora_api.pyxplora_api_async import PyXploraApi +from pyxplora_api.status import UserContactType from .const import ( CONF_HOME_LATITUDE, diff --git a/custom_components/xplora_watch/const_schema.py b/custom_components/xplora_watch/const_schema.py index dffeea8..18dd00e 100644 --- a/custom_components/xplora_watch/const_schema.py +++ b/custom_components/xplora_watch/const_schema.py @@ -3,7 +3,6 @@ from __future__ import annotations import voluptuous as vol - from homeassistant.const import CONF_COUNTRY_CODE, CONF_EMAIL, CONF_LANGUAGE, CONF_PASSWORD from homeassistant.helpers.selector import ( SelectOptionDict, diff --git a/custom_components/xplora_watch/coordinator.py b/custom_components/xplora_watch/coordinator.py index e936f79..da61fe4 100644 --- a/custom_components/xplora_watch/coordinator.py +++ b/custom_components/xplora_watch/coordinator.py @@ -7,11 +7,6 @@ from typing import Any import aiohttp -from pyxplora_api.const import DEFAULT_TIMEOUT -from pyxplora_api.model import ChatsNew -from pyxplora_api.pyxplora_api_async import PyXploraApi -from pyxplora_api.status import LocationType, WatchOnlineStatus - from homeassistant.components.device_tracker.const import ( ATTR_BATTERY, ATTR_LOCATION_NAME, @@ -27,6 +22,10 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import aiohttp_client from homeassistant.helpers.update_coordinator import DataUpdateCoordinator +from pyxplora_api.const import DEFAULT_TIMEOUT +from pyxplora_api.model import ChatsNew +from pyxplora_api.pyxplora_api_async import PyXploraApi +from pyxplora_api.status import LocationType, WatchOnlineStatus from .const import ( API_KEY_MAPBOX, diff --git a/custom_components/xplora_watch/helper.py b/custom_components/xplora_watch/helper.py index b12b313..c5f5193 100644 --- a/custom_components/xplora_watch/helper.py +++ b/custom_components/xplora_watch/helper.py @@ -10,14 +10,13 @@ from typing import Any from geopy import distance -from pydub import AudioSegment - from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, CONF_LANGUAGE from homeassistant.core import HomeAssistant from homeassistant.loader import DATA_CUSTOM_COMPONENTS from homeassistant.util.yaml import save_yaml from homeassistant.util.yaml.loader import load_yaml +from pydub import AudioSegment from .const import ( ATTR_SERVICE_DELETE_MSG, diff --git a/custom_components/xplora_watch/services.py b/custom_components/xplora_watch/services.py index a3dd19e..fa2e829 100644 --- a/custom_components/xplora_watch/services.py +++ b/custom_components/xplora_watch/services.py @@ -5,11 +5,10 @@ import logging from typing import Any -import voluptuous as vol -from pyxplora_api.exception_classes import NoAdminError - import homeassistant.helpers.config_validation as cv +import voluptuous as vol from homeassistant.core import HomeAssistant, ServiceCall, callback +from pyxplora_api.exception_classes import NoAdminError from .const import ( ATTR_SERVICE_DELETE_MSG, @@ -82,7 +81,7 @@ async def async_setup_services(hass: HomeAssistant, entry_id: str) -> None: async def async_see(service: ServiceCall) -> None: kwargs = dict(service.data) - await see_service.async_see(kwargs[ATTR_SERVICE_TARGET] if ATTR_SERVICE_TARGET in kwargs else ["all"], kwargs=kwargs) + await see_service.async_see(kwargs.get(ATTR_SERVICE_TARGET, ["all"]), kwargs=kwargs) async def async_delete_message_from_app(service: ServiceCall) -> None: kwargs = dict(service.data) diff --git a/custom_components/xplora_watch/switch.py b/custom_components/xplora_watch/switch.py index 63f7e2c..2663abc 100644 --- a/custom_components/xplora_watch/switch.py +++ b/custom_components/xplora_watch/switch.py @@ -5,8 +5,6 @@ import logging from typing import Any -from pyxplora_api.pyxplora_api_async import PyXploraApi - from homeassistant.components.switch import ( SwitchDeviceClass, SwitchEntity, @@ -16,6 +14,7 @@ from homeassistant.const import ATTR_ID, CONF_LANGUAGE, CONF_NAME from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback +from pyxplora_api.pyxplora_api_async import PyXploraApi from .const import ( ATTR_SERVICE_USER,