add option to use room uuid instead of room name

This commit is contained in:
Franzi 2024-10-31 21:54:24 +01:00
parent 927adfa0da
commit cc8bcc1233
3 changed files with 13 additions and 3 deletions

View file

@ -98,11 +98,11 @@
"itemname": "Room", "itemname": "Room",
"hint": "Define all rooms in your schedule and assign them to devices", "hint": "Define all rooms in your schedule and assign them to devices",
"items": [{ "items": [{
"title": "Room Name", "title": "Room Name or UUID",
"ui_width": 6, "ui_width": 6,
"name": "name", "name": "name",
"type": "string", "type": "string",
"hint": "Name of this room in your events native language", "hint": "Name of this room in your events native language or room UUID",
"default": "" "default": ""
}, { }, {
"title": "Serial", "title": "Serial",

10
service
View file

@ -91,10 +91,13 @@ def main():
else: else:
event_info = r.json() event_info = r.json()
room_uuid_mapping = {}
if event_info is not None: if event_info is not None:
event_start = datetime.strptime(event_info["start"], "%Y-%m-%d") event_start = datetime.strptime(event_info["start"], "%Y-%m-%d")
event_end = datetime.strptime(event_info["end"], "%Y-%m-%d") event_end = datetime.strptime(event_info["end"], "%Y-%m-%d")
event_tz = pytz.timezone(event_info["timezone"]) event_tz = pytz.timezone(event_info["timezone"])
for uuid, room_name in event_info.get("rooms", {}).items():
room_uuid_mapping[room_name] = uuid
try: try:
r = get( r = get(
@ -116,6 +119,7 @@ def main():
.astimezone(event_tz) .astimezone(event_tz)
.strftime("%H:%M") .strftime("%H:%M")
) )
talk["room_uuid"] = room_uuid_mapping.get("room")
if talk["track"]: if talk["track"]:
if talk["track"]["name"] not in tracks: if talk["track"]["name"] not in tracks:
tracks[talk["track"]["name"]] = talk["track"]["color"] tracks[talk["track"]["name"]] = talk["track"]["color"]
@ -142,6 +146,10 @@ def main():
"talks": [], "talks": [],
} }
room_uuid_mapping = {}
for room in raw_schedule["conference"]["rooms"]:
room_uuid_mapping[room["name"]] = room["guid"]
event_start = datetime.strptime( event_start = datetime.strptime(
raw_schedule["conference"]["start"][:10], "%Y-%m-%d" raw_schedule["conference"]["start"][:10], "%Y-%m-%d"
) )
@ -183,6 +191,8 @@ def main():
break break
talk["track"] = track talk["track"] = track
talk["room_uuid"] = room_uuid_mapping.get(talk["room"])
persons = [] persons = []
for p in talk["persons"]: for p in talk["persons"]:
name = p.get("public_name", p.get("name")) name = p.get("public_name", p.get("name"))

View file

@ -139,7 +139,7 @@ local function check_next_talks()
-- to announce these. -- to announce these.
if talk.end_ts > time and talk.start_ts > min_start then if talk.end_ts > time and talk.start_ts > min_start then
-- is this in *this* room, or somewhere else? -- is this in *this* room, or somewhere else?
if current_room and talk.room == current_room then if current_room and (talk.room == current_room or talk.room_uuid == current_room) then
room_next_talks[#room_next_talks+1] = talk room_next_talks[#room_next_talks+1] = talk
end end
all_next_talks[#all_next_talks+1] = talk all_next_talks[#all_next_talks+1] = talk