From 50c55dcfd30d15027155a8f1d05340238501522d Mon Sep 17 00:00:00 2001 From: RyanClark123 Date: Wed, 27 Mar 2024 15:51:12 +0000 Subject: [PATCH] Add binary sensor, correct interval input ### Feature *Base station on added as binary sensor ### Fix * Bumping pyowletapi to 2024.3.2 * UI config now allows you to set interval to 5 seconds, previously the minimum was 10 --- custom_components/owlet/binary_sensor.py | 6 +++++- custom_components/owlet/config_flow.py | 2 +- custom_components/owlet/manifest.json | 4 ++-- custom_components/owlet/strings.json | 3 +++ custom_components/owlet/translations/en.json | 5 ++++- custom_components/owlet/translations/uk.json | 3 +++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/custom_components/owlet/binary_sensor.py b/custom_components/owlet/binary_sensor.py index 6287fda..96c8b77 100644 --- a/custom_components/owlet/binary_sensor.py +++ b/custom_components/owlet/binary_sensor.py @@ -83,6 +83,11 @@ SENSORS: tuple[OwletBinarySensorEntityDescription, ...] = ( translation_key="awake", icon="mdi:sleep", ), + OwletBinarySensorEntityDescription( + key="base_station_on", + translation_key="base_on", + device_class=BinarySensorDeviceClass.POWER, + ), ) @@ -97,7 +102,6 @@ async def async_setup_entry( sensors = [] for coordinator in coordinators: - print(coordinator.sock.properties) for sensor in SENSORS: if sensor.key in coordinator.sock.properties: sensors.append(OwletBinarySensor(coordinator, sensor)) diff --git a/custom_components/owlet/config_flow.py b/custom_components/owlet/config_flow.py index 8f6bb9b..91ef91a 100644 --- a/custom_components/owlet/config_flow.py +++ b/custom_components/owlet/config_flow.py @@ -165,7 +165,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow): vol.Required( CONF_SCAN_INTERVAL, default=self.config_entry.options.get(CONF_SCAN_INTERVAL), - ): vol.All(vol.Coerce(int), vol.Range(min=10)), + ): vol.All(vol.Coerce(int), vol.Range(min=5)), } ) diff --git a/custom_components/owlet/manifest.json b/custom_components/owlet/manifest.json index f928287..2fb51c9 100644 --- a/custom_components/owlet/manifest.json +++ b/custom_components/owlet/manifest.json @@ -9,7 +9,7 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/ryanbdclark/owlet/issues", "requirements": [ - "pyowletapi==2023.11.4" + "pyowletapi==2024.3.2" ], - "version": "2023.11.2" + "version": "2024.3.1" } \ No newline at end of file diff --git a/custom_components/owlet/strings.json b/custom_components/owlet/strings.json index 08f123d..56c3550 100644 --- a/custom_components/owlet/strings.json +++ b/custom_components/owlet/strings.json @@ -74,6 +74,9 @@ }, "awake": { "name": "Awake" + }, + "base_on": { + "name": "Base station on" } }, "sensor": { diff --git a/custom_components/owlet/translations/en.json b/custom_components/owlet/translations/en.json index 5491965..93e2e99 100644 --- a/custom_components/owlet/translations/en.json +++ b/custom_components/owlet/translations/en.json @@ -74,7 +74,10 @@ }, "awake": { "name": "Awake" - } + }, + "base_on": { + "name": "Base station on" + } }, "sensor": { "batterypercent": { diff --git a/custom_components/owlet/translations/uk.json b/custom_components/owlet/translations/uk.json index 08f123d..56c3550 100644 --- a/custom_components/owlet/translations/uk.json +++ b/custom_components/owlet/translations/uk.json @@ -74,6 +74,9 @@ }, "awake": { "name": "Awake" + }, + "base_on": { + "name": "Base station on" } }, "sensor": {