From 0cf3afef85d82c8ea7b856346c3a3e96ecf300df Mon Sep 17 00:00:00 2001 From: RyanClark123 Date: Wed, 17 May 2023 18:59:38 +0100 Subject: [PATCH] Bumping pyowlet, reauth config entry fix #### Fix * Bumping to pyowletapi 2023.5.24 * Reauthing now no longer re adds users' password to config entry --- CHANGELOG.md | 5 +++++ custom_components/owlet/config_flow.py | 9 +++------ custom_components/owlet/const.py | 2 +- custom_components/owlet/manifest.json | 4 ++-- custom_components/owlet/sensor.py | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0c9673..cf8f0be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog +## 2023-05-3 (2023-05-17) +#### Fix +* Bumping to pyowletapi 2023.5.24 +* Reauthing now no longer re adds users' password to config entry + ## 2023-05-2 (2023-05-16) #### Feature * Integration now makes use of refresh token from pyowletapi to reauthenticate, user password in no longer stored by integration ([`dc710a1`](https://github.com/ryanbdclark/owlet/commit/dc710a1783a4cad9d6cf355240fe12ac779a87ef)) diff --git a/custom_components/owlet/config_flow.py b/custom_components/owlet/config_flow.py index 9115a45..95b2637 100644 --- a/custom_components/owlet/config_flow.py +++ b/custom_components/owlet/config_flow.py @@ -138,12 +138,9 @@ class OwletConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): try: token = await owlet_api.authenticate() if token: - user_input[CONF_API_TOKEN] = token[CONF_API_TOKEN] - user_input[CONF_OWLET_EXPIRY] = token[CONF_OWLET_EXPIRY] - user_input[CONF_OWLET_REFRESH] = token[CONF_OWLET_REFRESH] - self.hass.config_entries.async_update_entry( - self.reauth_entry, data={**entry_data, **user_input} - ) + self.hass.config_entries.async_update_entry( + self.reauth_entry, data={**entry_data, **token} + ) await self.hass.config_entries.async_reload(self.reauth_entry.entry_id) diff --git a/custom_components/owlet/const.py b/custom_components/owlet/const.py index c574fe2..61d5615 100644 --- a/custom_components/owlet/const.py +++ b/custom_components/owlet/const.py @@ -8,4 +8,4 @@ CONF_OWLET_REFRESH = "refresh" SUPPORTED_VERSIONS = [3] POLLING_INTERVAL = 5 MANUFACTURER = "Owlet Baby Care" -SLEEP_STATES = {1: "Awake", 8: "Light Sleep", 15: "Deep Sleep"} +SLEEP_STATES = {0: "Unknown", 1: "Awake", 8: "Light Sleep", 15: "Deep Sleep"} diff --git a/custom_components/owlet/manifest.json b/custom_components/owlet/manifest.json index cda4a71..f949e65 100644 --- a/custom_components/owlet/manifest.json +++ b/custom_components/owlet/manifest.json @@ -10,7 +10,7 @@ "homekit": {}, "iot_class": "cloud_polling", "requirements": [ - "pyowletapi==2023.5.23" + "pyowletapi==2023.5.24" ], - "version":"2023.5.2" + "version":"2023.5.3" } diff --git a/custom_components/owlet/sensor.py b/custom_components/owlet/sensor.py index a103c12..a3e23ad 100644 --- a/custom_components/owlet/sensor.py +++ b/custom_components/owlet/sensor.py @@ -170,4 +170,4 @@ class OwletSleepStateSensor(OwletBaseEntity, SensorEntity): @property def options(self) -> list[str]: - return ["Awake", "Light Sleep", "Deep Sleep"] + return SLEEP_STATES.values()