4 Commits

Author SHA1 Message Date
RyanClark123
f8e0067a1e Revert to pyowletapi 2025.4.1 2025-04-15 19:56:21 +01:00
RyanClark123
45e65f384b Updating version in manifest and changelog 2025-04-15 19:14:31 +01:00
ryanbdclark
df6b45621e Merge pull request #25 from MarjovanLier/fix-multiple-devices
(Fixed) Ensure entities from multiple Owlet devices register correctly
2025-04-15 19:08:46 +01:00
Marjo Wenzel van Lier
1244bffcb4 fix(entity): Ensure entities from multiple devices register correctly
- Modify sensor and switch setup to use `extend` instead of list
  reassignment. This prevents overwriting entities from previously
  processed devices.
- Update `OwletBaseEntity` initialisation to correctly store the
  coordinator instance.
- Refine device information retrieval using `getattr` for enhanced
  robustness and provide more specific device details (e.g., serial
  number in name).

This change addresses a bug where, in setups with multiple Owlet devices,
only the entities belonging to the last device in the configuration
were registered. Using `extend` ensures all entities across all devices
are correctly added. Device information presentation is also improved.
2025-04-15 00:36:04 +02:00
6 changed files with 22 additions and 14 deletions

View File

@@ -1,13 +1,17 @@
# Changelog
<!--next-version-placeholder-->
## 2025.4.3 (2025-04-15)
### Fix
* Changes to how the sensors are stored to solve the issue where only one device is added, thanks [`@MarjovanLier`](https://github.com/MarjovanLier). ([`1244bff`](https://github.com/ryanbdclark/owlet/commit/1244bffcb48d7337a9d7a0da518959fe4b31a230))
## 2025.4.2 (2025-04-14)
### Fix
* Bumping pyowletapi to 2025.4.1, should hopefully stop issue where only one device was added to HA.
* Bumping pyowletapi to 2025.4.1, should hopefully stop issue where only one device was added to HA. ([`d323cbf`](https://github.com/ryanbdclark/owlet/commit/d323cbfd11411ff34866ead492de10c109c72689))
## 2025.4.1 (2025-04-11)
### Fix
* Changes to stop errors after refactoring pyowletapi
* Changes to stop errors after refactoring pyowletapi ([`6b343a7`](https://github.com/ryanbdclark/owlet/commit/6b343a76caad3375e10c80f4d26942a1bbbb831d))
## 2025.4.0 (2025-04-11)
### Fix

View File

@@ -106,11 +106,11 @@ async def async_setup_entry(
sensors = []
for coordinator in coordinators:
sensors = [
sensors.extend([
OwletBinarySensor(coordinator, sensor)
for sensor in SENSORS
if sensor.key in coordinator.sock.properties
]
])
if OwletAwakeSensor.entity_description.key in coordinator.sock.properties:
sensors.append(OwletAwakeSensor(coordinator))

View File

@@ -19,6 +19,7 @@ class OwletBaseEntity(CoordinatorEntity[OwletCoordinator], Entity):
) -> None:
"""Initialize the base entity."""
super().__init__(coordinator)
self.coordinator = coordinator
self.sock = coordinator.sock
@property
@@ -26,9 +27,12 @@ class OwletBaseEntity(CoordinatorEntity[OwletCoordinator], Entity):
"""Return the device info of the device."""
return DeviceInfo(
identifiers={(DOMAIN, self.sock.serial)},
name="Owlet Baby Care Sock",
manufacturer=MANUFACTURER,
model=self.sock.model,
sw_version=self.sock.sw_version,
hw_version=f"{self.sock.version}r{self.sock.revision}",
name=f"Owlet Sock {self.sock.serial}",
connections={("mac", getattr(self.sock, "mac", "unknown"))},
suggested_area="Nursery",
configuration_url="https://my.owletcare.com/",
manufacturer="Owlet Baby Care",
model=getattr(self.sock, "model", None),
sw_version=getattr(self.sock, "sw_version", None),
hw_version=getattr(self.sock, "hw_version", "3r8"),
)

View File

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

View File

@@ -115,11 +115,11 @@ async def async_setup_entry(
sensors = []
for coordinator in coordinators:
sensors = [
sensors.extend([
OwletSensor(coordinator, sensor)
for sensor in SENSORS
if sensor.key in coordinator.sock.properties
]
])
if OwletSleepSensor.entity_description.key in coordinator.sock.properties:
sensors.append(OwletSleepSensor(coordinator))

View File

@@ -52,7 +52,7 @@ async def async_setup_entry(
switches = []
for coordinator in coordinators:
switches = [OwletBaseSwitch(coordinator, switch) for switch in SWITCHES]
switches.extend([OwletBaseSwitch(coordinator, switch) for switch in SWITCHES])
async_add_entities(switches)