From 5e17ecdeb2aca5bbb35f19ca5795a2c5e0f776ab Mon Sep 17 00:00:00 2001 From: coreywillwhat <104224685+coreywillwhat@users.noreply.github.com> Date: Tue, 7 May 2024 11:32:15 -0600 Subject: [PATCH] fix: O2 Sat 10m Avg reporting `255%` Just a suggestion! The O2 Sat 10m average reports `255%` when not charging, and before it can calculate the 10m average. Suggest changing to report `None` until the average can be displayed. This way the graphs/data aren't skewed by the 255 value. --- custom_components/owlet/sensor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/owlet/sensor.py b/custom_components/owlet/sensor.py index 3a979ec..15697ea 100644 --- a/custom_components/owlet/sensor.py +++ b/custom_components/owlet/sensor.py @@ -157,6 +157,12 @@ class OwletSensor(OwletBaseEntity, SensorEntity): if self.entity_description.key == "sleep_state": return SLEEP_STATES[self.sock.properties["sleep_state"]] + if self.entity_description.key == "oxygen_10_av": + val = self.sock.properties[self.entity_description.key] + if val is None or not isinstance(val, (int, float)) or val < 0 or val > 100: + return None + return val + return self.sock.properties[self.entity_description.key] @property