2 Commits

Author SHA1 Message Date
ryanbdclark
1cfff537d7 Update CHANGELOG.md 2023-11-16 11:45:00 +00:00
RyanClark123
3acf847352 Correcting error where properties may not exist
### Fix
* Bumping pyowletapi to 2023.11.1
* Sensors and binary sensors are now only created where the sock contains that property, this stops errors where different sock versions have different properties
2023-11-16 11:42:34 +00:00
4 changed files with 18 additions and 18 deletions

View File

@@ -1,6 +1,11 @@
# Changelog # Changelog
<!--next-version-placeholder--> <!--next-version-placeholder-->
## 2023.11.1 (2023-11-16)
### Fix
* Bumping pyowletapi to 2023.11.1 ([`3acf847`](https://github.com/ryanbdclark/owlet/commit/3acf8473526665382b44ef6325d708a6c62fff45))
* Sensors and binary sensors are now only created where the sock contains that property, this stops errors where different sock versions have different properties ([`3acf847`](https://github.com/ryanbdclark/owlet/commit/3acf8473526665382b44ef6325d708a6c62fff45))
## 2023.9.1 (2023-09-20) ## 2023.9.1 (2023-09-20)
### Fix ### Fix
* Bumping pyowletapi to 2023.9.1 to allow for revisions ([`0a7f703`](https://github.com/ryanbdclark/owlet/commit/0a7f70310080a129c988e9607331baa2f6c691e0)) * Bumping pyowletapi to 2023.9.1 to allow for revisions ([`0a7f703`](https://github.com/ryanbdclark/owlet/commit/0a7f70310080a129c988e9607331baa2f6c691e0))

View File

@@ -85,12 +85,13 @@ async def async_setup_entry(
coordinators: OwletCoordinator = hass.data[DOMAIN][config_entry.entry_id].values() coordinators: OwletCoordinator = hass.data[DOMAIN][config_entry.entry_id].values()
async_add_entities( sensors = []
OwletBinarySensor(coordinator, sensor) for coordinator in coordinators:
for coordinator in coordinators for sensor in SENSORS:
for sensor in SENSORS if sensor.key in coordinator.sock.properties:
) sensors.append(OwletBinarySensor(coordinator, sensor))
async_add_entities(sensors)
class OwletBinarySensor(OwletBaseEntity, BinarySensorEntity): class OwletBinarySensor(OwletBaseEntity, BinarySensorEntity):
"""Representation of an Owlet binary sensor.""" """Representation of an Owlet binary sensor."""

View File

@@ -9,7 +9,7 @@
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"issue_tracker": "https://github.com/ryanbdclark/owlet/issues", "issue_tracker": "https://github.com/ryanbdclark/owlet/issues",
"requirements": [ "requirements": [
"pyowletapi==2023.9.1" "pyowletapi==2023.11.1"
], ],
"version": "2023.9.1" "version": "2023.11.1"
} }

View File

@@ -30,7 +30,7 @@ class OwletSensorEntityDescription(SensorEntityDescription):
"""Represent the owlet sensor entity description.""" """Represent the owlet sensor entity description."""
SENSORS_ALL: tuple[OwletSensorEntityDescription, ...] = ( SENSORS: tuple[OwletSensorEntityDescription, ...] = (
OwletSensorEntityDescription( OwletSensorEntityDescription(
key="battery_percentage", key="battery_percentage",
translation_key="batterypercent", translation_key="batterypercent",
@@ -85,9 +85,6 @@ SENSORS_ALL: tuple[OwletSensorEntityDescription, ...] = (
icon="mdi:cursor-move", icon="mdi:cursor-move",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
)
SENSORS_OLD: tuple[OwletSensorEntityDescription, ...] = (
OwletSensorEntityDescription( OwletSensorEntityDescription(
key="oxygen_10_av", key="oxygen_10_av",
translation_key="o2saturation10a", translation_key="o2saturation10a",
@@ -118,13 +115,10 @@ async def async_setup_entry(
sensors = [] sensors = []
sensor_list = SENSORS_ALL
for coordinator in coordinators: for coordinator in coordinators:
if coordinator.sock.revision < 5: for sensor in SENSORS:
sensor_list += SENSORS_OLD if sensor.key in coordinator.sock.properties:
sensors.append(OwletSensor(coordinator, sensor))
for sensor in sensor_list:
sensors.append(OwletSensor(coordinator, sensor))
async_add_entities(sensors) async_add_entities(sensors)