Skip to content

Commit 6477d32

Browse files
committed
Update devices.py
Petite passe passe pour enlever le warning au startup pour device 0.
1 parent 077b401 commit 6477d32

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pyhilo/devices.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ def _map_readings_to_devices(
5858
device_identifier: Union[int, str] = reading.device_id
5959
if device_identifier == 0:
6060
device_identifier = reading.hilo_id
61-
if device := self.find_device(device_identifier):
61+
device = self.find_device(device_identifier)
62+
# If device_id was 0 and hilo_id lookup failed, this is likely
63+
# a gateway reading that arrives before GatewayValuesReceived
64+
# assigns the real ID. Fall back to the gateway device.
65+
if device is None and reading.device_id == 0:
66+
device = next((d for d in self.devices if d.type == "Gateway"), None)
67+
if device:
6268
device.update_readings(reading)
6369
LOG.debug("%s Received %s", device, reading)
6470
if device not in updated_devices:

0 commit comments

Comments
 (0)