We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 077b401 commit 6477d32Copy full SHA for 6477d32
1 file changed
pyhilo/devices.py
@@ -58,7 +58,13 @@ def _map_readings_to_devices(
58
device_identifier: Union[int, str] = reading.device_id
59
if device_identifier == 0:
60
device_identifier = reading.hilo_id
61
- if device := self.find_device(device_identifier):
+ 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:
68
device.update_readings(reading)
69
LOG.debug("%s Received %s", device, reading)
70
if device not in updated_devices:
0 commit comments