From 9b9773c74da251936df00ebc455dfa52e43de760 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sun, 23 Oct 2022 22:28:34 +0200 Subject: [PATCH 1/3] Update aiobiketrax to 0.4.0 --- custom_components/biketrax/manifest.json | 2 +- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/biketrax/manifest.json b/custom_components/biketrax/manifest.json index 0b5d092..d6164a5 100644 --- a/custom_components/biketrax/manifest.json +++ b/custom_components/biketrax/manifest.json @@ -8,7 +8,7 @@ "iot_class": "cloud_polling", "issue_tracker": "https://www.github.com/basilfx/homeassistant-biketrax/issues", "name": "PowUnity BikeTrax", - "requirements": ["aiobiketrax==0.3.0"], + "requirements": ["aiobiketrax==0.4.0"], "ssdp": [], "version": "0.3.0", "zeroconf": [] diff --git a/poetry.lock b/poetry.lock index 81a0df2..67630fd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,6 +1,6 @@ [[package]] name = "aiobiketrax" -version = "0.3.0" +version = "0.4.0" description = "Python library for interacting with the PowUnity BikeTrax GPS tracker." category = "main" optional = false @@ -864,12 +864,12 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "fbdc579fa039b90560934f8427203b384cd6fe9176934f07ac05b238387455c8" +content-hash = "167d34d4b4f6cb4dce0ee136d21d10d8ee935063c9937216dd4d4e2b80099dfa" [metadata.files] aiobiketrax = [ - {file = "aiobiketrax-0.3.0-py3-none-any.whl", hash = "sha256:c6e562450d9a47b11ff24b2136e1f836dbdcfe3ffedcdfa6423439f74ee30615"}, - {file = "aiobiketrax-0.3.0.tar.gz", hash = "sha256:a7fb94efd0e609555dbb072377e2a20e09c43f9d26a53ba1ab53811e86e25c25"}, + {file = "aiobiketrax-0.4.0-py3-none-any.whl", hash = "sha256:4024522d8fa8290079fb2dd90f2c1159c10cd3e90108bf2735ab967c06e45e61"}, + {file = "aiobiketrax-0.4.0.tar.gz", hash = "sha256:73e0722bd1067a71c08304e14c64da6f66ee945e7f54e70c7927a37b44b0633b"}, ] aiohttp = [ {file = "aiohttp-3.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1ed0b6477896559f17b9eaeb6d38e07f7f9ffe40b9f0f9627ae8b9926ae260a8"}, diff --git a/pyproject.toml b/pyproject.toml index 352a981..8e7523e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ python = "^3.9" homeassistant = "^2022.10.0" flake8 = "^5.0.4" flake8-mypy = "^17.8.0" -aiobiketrax = {version = "^0.3.0", allow-prereleases = true} +aiobiketrax = {version = "^0.4.0", allow-prereleases = true} [tool.poetry.dev-dependencies] pytest = "^7.1" From 920a1474ec102a1dd8931e4a94f631d397c01d19 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sun, 23 Oct 2022 20:58:38 +0200 Subject: [PATCH 2/3] Add binary sensor for alarm This is the binary version of the control panel, and works 'better' with read-only mode. Also rename 'guarded' to 'alarm'. This makes it more clear and is in line with the PowUnity app. --- custom_components/biketrax/binary_sensor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/custom_components/biketrax/binary_sensor.py b/custom_components/biketrax/binary_sensor.py index 67b3daa..bd3f118 100644 --- a/custom_components/biketrax/binary_sensor.py +++ b/custom_components/biketrax/binary_sensor.py @@ -34,6 +34,12 @@ class BikeTraxBinarySensorEntityDescription( SENSOR_TYPES: tuple[BikeTraxBinarySensorEntityDescription, ...] = ( + BikeTraxBinarySensorEntityDescription( + coordinator=DATA_DEVICE, + key="is_guarded", + name="Alarm enabled", + icon="mdi:shield-lock", + ), BikeTraxBinarySensorEntityDescription( coordinator=DATA_DEVICE, key="is_alarm_triggered", @@ -43,7 +49,7 @@ class BikeTraxBinarySensorEntityDescription( BikeTraxBinarySensorEntityDescription( coordinator=DATA_DEVICE, key="is_auto_guarded", - name="Auto guarded", + name="Auto alarm enabled", icon="mdi:account-lock", ), ) From b4041dea11d233e530e335bdc6af5d13c7c2807f Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sun, 23 Oct 2022 21:46:21 +0200 Subject: [PATCH 3/3] Add auto alarm type and geofence radius sensors --- custom_components/biketrax/sensor.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/custom_components/biketrax/sensor.py b/custom_components/biketrax/sensor.py index 7bee3d7..bc38d68 100644 --- a/custom_components/biketrax/sensor.py +++ b/custom_components/biketrax/sensor.py @@ -14,7 +14,9 @@ ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( + LENGTH_FEET, LENGTH_KILOMETERS, + LENGTH_METERS, LENGTH_MILES, PERCENTAGE, SPEED_KILOMETERS_PER_HOUR, @@ -101,6 +103,23 @@ class BikeTraxSensorEntityDescription( key="last_updated", name="Last updated", ), + BikeTraxSensorEntityDescription( + coordinator=DATA_DEVICE, + icon="mdi:border-radius", + key="guard_type", + name="Auto alarm type", + ), + BikeTraxSensorEntityDescription( + coordinator=DATA_DEVICE, + icon="mdi:map-marker-distance", + imperial_conversion=lambda val: distance_convert( + val, LENGTH_METERS, LENGTH_FEET + ), + key="geofence_radius", + name="Auto alarm geofence radius", + unit_imperial=LENGTH_FEET, + unit_metric=LENGTH_METERS, + ), )