From f7a17c33ad693cd5c539e6d1bfe70013b96ba313 Mon Sep 17 00:00:00 2001 From: dvirlabs <114520947+dvirlabs@users.noreply.github.com> Date: Fri, 18 Jul 2025 19:23:25 +0300 Subject: [PATCH] Update the script of uptimekuma --- automation/uptime-kuma/sync_kuma.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/automation/uptime-kuma/sync_kuma.py b/automation/uptime-kuma/sync_kuma.py index 1ea8a7b..d835da6 100644 --- a/automation/uptime-kuma/sync_kuma.py +++ b/automation/uptime-kuma/sync_kuma.py @@ -35,14 +35,23 @@ def sync_monitor(api, path): print(f"🔄 Syncing monitor: {name}") - # Create or get tag + # Get or create tag safely tag_id = None for tag in api.get_tags(): if tag["name"] == tag_name: tag_id = tag["id"] break + if not tag_id: - tag_id = api.add_tag(name=tag_name, color="#2196f3")["tagID"] + tag_resp = api.add_tag(name=tag_name, color="#2196f3") + tag_id = tag_resp.get("tagID") + if not tag_id: + for tag in api.get_tags(): + if tag["name"] == tag_name: + tag_id = tag["id"] + break + if not tag_id: + raise Exception(f"❌ Failed to create or find tag: {tag_name}") # Prepare Basic Auth using Kuma credentials auth_kwargs = {