From 33a6352d42e39bda68003e593ddfc708017f33b6 Mon Sep 17 00:00:00 2001 From: Ludy Date: Sun, 28 Jan 2024 14:20:46 +0100 Subject: [PATCH] v2.13.3 Beta (#365) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Features • Added support for the Xplora® Watch Version 2 in various modules, enhancing functionality and user experience. ## Fixes & Improvements • Improved code readability and maintenance by adding whitespace in multiple files. • Enhanced configuration flow for user sign-in, making it more robust and user-friendly. • Updated the device tracker's logic for tracking and displaying watch location and status, offering more accurate and detailed information. ## Technical Updates • Updated the pyxplora_api library version from 2.12.3 to 2.12.4, ensuring better compatibility and performance. • Upgraded the integration version to v2.13.3.beta, reflecting the latest changes and improvements. --- custom_components/xplora_watch/__init__.py | 1 + custom_components/xplora_watch/binary_sensor.py | 1 + custom_components/xplora_watch/config_flow.py | 9 ++++++--- custom_components/xplora_watch/const.py | 1 + custom_components/xplora_watch/const_schema.py | 1 + custom_components/xplora_watch/coordinator.py | 1 + custom_components/xplora_watch/device_tracker.py | 13 +++++++------ custom_components/xplora_watch/entity.py | 1 + custom_components/xplora_watch/geocoder.py | 1 + custom_components/xplora_watch/helper.py | 1 + custom_components/xplora_watch/manifest.json | 4 ++-- custom_components/xplora_watch/notify.py | 1 + custom_components/xplora_watch/sensor.py | 1 + custom_components/xplora_watch/services.py | 1 + custom_components/xplora_watch/switch.py | 9 ++++++--- 15 files changed, 32 insertions(+), 14 deletions(-) diff --git a/custom_components/xplora_watch/__init__.py b/custom_components/xplora_watch/__init__.py index 51d1301b..a201ed19 100644 --- a/custom_components/xplora_watch/__init__.py +++ b/custom_components/xplora_watch/__init__.py @@ -1,4 +1,5 @@ """Support for Xplora® Watch Version 2.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/binary_sensor.py b/custom_components/xplora_watch/binary_sensor.py index 81507df7..3d1647dc 100644 --- a/custom_components/xplora_watch/binary_sensor.py +++ b/custom_components/xplora_watch/binary_sensor.py @@ -1,4 +1,5 @@ """Reads watch status from Xplora® Watch Version 2.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/config_flow.py b/custom_components/xplora_watch/config_flow.py index 17bb3d51..f1590599 100644 --- a/custom_components/xplora_watch/config_flow.py +++ b/custom_components/xplora_watch/config_flow.py @@ -1,4 +1,5 @@ """Config flow for Xplora® Watch Version 2.""" + from __future__ import annotations import logging @@ -342,9 +343,11 @@ async def async_step_init(self, user_input: dict[str, Any] | None = None) -> Flo language: str = _options.get(CONF_LANGUAGE, self.config_entry.data.get(CONF_LANGUAGE, DEFAULT_LANGUAGE)) signin_typ = [ - SIGNIN.get(language, SIGNIN[DEFAULT_LANGUAGE]).get(CONF_EMAIL) - if CONF_EMAIL in self.config_entry.data - else SIGNIN.get(language, SIGNIN[DEFAULT_LANGUAGE]).get(CONF_PHONENUMBER) + ( + SIGNIN.get(language, SIGNIN[DEFAULT_LANGUAGE]).get(CONF_EMAIL) + if CONF_EMAIL in self.config_entry.data + else SIGNIN.get(language, SIGNIN[DEFAULT_LANGUAGE]).get(CONF_PHONENUMBER) + ) ] _home_zone = self.hass.states.get(HOME).attributes diff --git a/custom_components/xplora_watch/const.py b/custom_components/xplora_watch/const.py index bb8eb472..ff3edbbc 100644 --- a/custom_components/xplora_watch/const.py +++ b/custom_components/xplora_watch/const.py @@ -1,4 +1,5 @@ """Const for Xplora® Watch Version 2.""" + from __future__ import annotations from typing import Final diff --git a/custom_components/xplora_watch/const_schema.py b/custom_components/xplora_watch/const_schema.py index 72cd7278..e003ad30 100644 --- a/custom_components/xplora_watch/const_schema.py +++ b/custom_components/xplora_watch/const_schema.py @@ -1,4 +1,5 @@ """Const schema for Xplora® Watch Version 2.""" + from __future__ import annotations import voluptuous as vol diff --git a/custom_components/xplora_watch/coordinator.py b/custom_components/xplora_watch/coordinator.py index dac259ba..633f5603 100644 --- a/custom_components/xplora_watch/coordinator.py +++ b/custom_components/xplora_watch/coordinator.py @@ -1,4 +1,5 @@ """Coordinator for Xplora® Watch Version 2.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/device_tracker.py b/custom_components/xplora_watch/device_tracker.py index c1a99b5b..a7648f2a 100644 --- a/custom_components/xplora_watch/device_tracker.py +++ b/custom_components/xplora_watch/device_tracker.py @@ -1,4 +1,5 @@ """Support for Xplora® Watch Version 2 tracking.""" + from __future__ import annotations import logging @@ -235,12 +236,12 @@ def extra_state_attributes(self) -> dict[str, Any]: **{ ATTR_SERVICE_USER: self.coordinator.username, ATTR_TRACKER_DISTOHOME: distance_to_home, - ATTR_TRACKER_ADDR: self.coordinator.data[self.watch_uid].get(ATTR_LOCATION_NAME, None) - if distance_to_home - else None, - ATTR_TRACKER_LAST_TRACK: self.coordinator.data[self.watch_uid].get("lastTrackTime", None) - if distance_to_home - else None, + ATTR_TRACKER_ADDR: ( + self.coordinator.data[self.watch_uid].get(ATTR_LOCATION_NAME, None) if distance_to_home else None + ), + ATTR_TRACKER_LAST_TRACK: ( + self.coordinator.data[self.watch_uid].get("lastTrackTime", None) if distance_to_home else None + ), ATTR_TRACKER_IMEI: self.coordinator.data[self.watch_uid].get(ATTR_TRACKER_IMEI, None), ATTR_TRACKER_POI: self.coordinator.data[self.watch_uid].get(ATTR_TRACKER_POI, None), ATTR_TRACKER_LICENCE: self.coordinator.data[self.watch_uid].get(ATTR_TRACKER_LICENCE, None), diff --git a/custom_components/xplora_watch/entity.py b/custom_components/xplora_watch/entity.py index 446ea172..65558f0f 100644 --- a/custom_components/xplora_watch/entity.py +++ b/custom_components/xplora_watch/entity.py @@ -1,4 +1,5 @@ """Entity for Xplora® Watch Version 2 tracking.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/geocoder.py b/custom_components/xplora_watch/geocoder.py index ee9284ec..3cffc02b 100644 --- a/custom_components/xplora_watch/geocoder.py +++ b/custom_components/xplora_watch/geocoder.py @@ -8,6 +8,7 @@ Version: 2.4.0 https://raw.githubusercontent.com/OpenCageData/python-opencage-geocoder/master/LICENSE.txt """ + from __future__ import annotations import collections diff --git a/custom_components/xplora_watch/helper.py b/custom_components/xplora_watch/helper.py index 70188189..b12b3134 100644 --- a/custom_components/xplora_watch/helper.py +++ b/custom_components/xplora_watch/helper.py @@ -1,4 +1,5 @@ """HelperClasses Xplora® Watch Version 2.""" + from __future__ import annotations import base64 diff --git a/custom_components/xplora_watch/manifest.json b/custom_components/xplora_watch/manifest.json index eac35a0e..caa18860 100644 --- a/custom_components/xplora_watch/manifest.json +++ b/custom_components/xplora_watch/manifest.json @@ -9,7 +9,7 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/Ludy87/xplora_watch/issues", "requirements": [ - "pyxplora_api==2.12.3", + "pyxplora_api==2.12.4", "backoff==2.2.1", "requests==2.31.0", "aiohttp==3.9.1", @@ -18,5 +18,5 @@ "pydub", "marshmallow-enum" ], - "version": "v2.13.2" + "version": "v2.13.3-beta" } diff --git a/custom_components/xplora_watch/notify.py b/custom_components/xplora_watch/notify.py index b7de3d71..d2acd2e0 100644 --- a/custom_components/xplora_watch/notify.py +++ b/custom_components/xplora_watch/notify.py @@ -1,4 +1,5 @@ """Send Message to watch from Xplora® Watch Version 2.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/sensor.py b/custom_components/xplora_watch/sensor.py index 74665690..655b7ae0 100644 --- a/custom_components/xplora_watch/sensor.py +++ b/custom_components/xplora_watch/sensor.py @@ -1,4 +1,5 @@ """Reads watch status from Xplora® Watch Version 2.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/services.py b/custom_components/xplora_watch/services.py index cbb7517e..a3dd19e5 100644 --- a/custom_components/xplora_watch/services.py +++ b/custom_components/xplora_watch/services.py @@ -1,4 +1,5 @@ """Support for Xplora® Watch Version 2 send/read message, manually refresh and shutdown.""" + from __future__ import annotations import logging diff --git a/custom_components/xplora_watch/switch.py b/custom_components/xplora_watch/switch.py index 7437bc49..63f7e2c4 100644 --- a/custom_components/xplora_watch/switch.py +++ b/custom_components/xplora_watch/switch.py @@ -1,4 +1,5 @@ """Reads watch status from Xplora® Watch Version 2.""" + from __future__ import annotations import logging @@ -204,9 +205,11 @@ def __init__( self._silent = silent - self._attr_name: str = f'{ward.get(CONF_NAME)} {ATTR_WATCH} {description.key} {silent["start"]}-{silent["end"]} ({coordinator.username})'.replace( # noqa: E501 - "_", " " - ).title() + self._attr_name: str = ( + f'{ward.get(CONF_NAME)} {ATTR_WATCH} {description.key} {silent["start"]}-{silent["end"]} ({coordinator.username})'.replace( # noqa: E501 + "_", " " + ).title() + ) self._attr_unique_id = ( f'{ward.get(CONF_NAME)}_{ATTR_WATCH}_{description.key}_{silent["vendorId"]}_{wuid}_{coordinator.user_id}'.replace(