diff --git a/custom_components/owlet/binary_sensor.py b/custom_components/owlet/binary_sensor.py index 7854b66..36cf032 100644 --- a/custom_components/owlet/binary_sensor.py +++ b/custom_components/owlet/binary_sensor.py @@ -85,12 +85,13 @@ async def async_setup_entry( coordinators: OwletCoordinator = hass.data[DOMAIN][config_entry.entry_id].values() - async_add_entities( - OwletBinarySensor(coordinator, sensor) - for coordinator in coordinators - for sensor in SENSORS - ) - + sensors = [] + for coordinator in coordinators: + for sensor in SENSORS: + if sensor.key in coordinator.sock.properties: + sensors.append(OwletBinarySensor(coordinator, sensor)) + + async_add_entities(sensors) class OwletBinarySensor(OwletBaseEntity, BinarySensorEntity): """Representation of an Owlet binary sensor.""" diff --git a/custom_components/owlet/manifest.json b/custom_components/owlet/manifest.json index 3969988..d286c16 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.9.1" + "pyowletapi==2023.11.1" ], - "version": "2023.9.1" + "version": "2023.11.1" } \ No newline at end of file diff --git a/custom_components/owlet/sensor.py b/custom_components/owlet/sensor.py index b091dc3..52821c1 100644 --- a/custom_components/owlet/sensor.py +++ b/custom_components/owlet/sensor.py @@ -30,7 +30,7 @@ class OwletSensorEntityDescription(SensorEntityDescription): """Represent the owlet sensor entity description.""" -SENSORS_ALL: tuple[OwletSensorEntityDescription, ...] = ( +SENSORS: tuple[OwletSensorEntityDescription, ...] = ( OwletSensorEntityDescription( key="battery_percentage", translation_key="batterypercent", @@ -85,9 +85,6 @@ SENSORS_ALL: tuple[OwletSensorEntityDescription, ...] = ( icon="mdi:cursor-move", entity_registry_enabled_default=False, ), -) - -SENSORS_OLD: tuple[OwletSensorEntityDescription, ...] = ( OwletSensorEntityDescription( key="oxygen_10_av", translation_key="o2saturation10a", @@ -118,13 +115,10 @@ async def async_setup_entry( sensors = [] - sensor_list = SENSORS_ALL for coordinator in coordinators: - if coordinator.sock.revision < 5: - sensor_list += SENSORS_OLD - - for sensor in sensor_list: - sensors.append(OwletSensor(coordinator, sensor)) + for sensor in SENSORS: + if sensor.key in coordinator.sock.properties: + sensors.append(OwletSensor(coordinator, sensor)) async_add_entities(sensors)