handle case if device config doesnt exists

This commit is contained in:
2024-07-07 11:53:06 +02:00
parent d7b3303e50
commit 7415bb8112
4 changed files with 18 additions and 3 deletions

View File

@@ -1,8 +0,0 @@
devices:
- mac: A4:C1:38:00:00:00
name: "my_device_1"
room: "my_room_1"
- mac: A4:C1:38:00:00:00
name: "my_device_2"
room: "my_room_2"

View File

@@ -30,8 +30,8 @@ def log_to_json(devices):
"battery_percent": data_obj.battery_percent,
"battery_volt": data_obj.battery_volt,
"rssi": dev.rssi,
"name": from_config.name,
"room": from_config.room
"name": from_config.name if from_config is not None else "Unknown",
"room": from_config.room if from_config is not None else "Unknown"
}
data.append(measurements)