From 5a5db043a9dec84f99d455e355197a7288141c2e Mon Sep 17 00:00:00 2001 From: "Bruno J." Date: Thu, 3 Jul 2025 15:55:04 +0000 Subject: [PATCH] added ha-python scripts --- Template-YT.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Template-YT.py diff --git a/Template-YT.py b/Template-YT.py new file mode 100644 index 0000000..17dbad6 --- /dev/null +++ b/Template-YT.py @@ -0,0 +1,23 @@ +import requests + +# Home Assistant Einstellungen +HASS_URL = "http://IP_ADRESSE:8123/api/services/switch/toggle" # oder auch /light/toggle, usw +TOKEN = "API Token von Home Assistant" + +# Service-Daten (zum Beispiel, um eine Licht zu schalten) +data = { + "entity_id": "switch.template" # oder auch light.licht +} + +# HTTP-Anfrage an Home Assistant senden +headers = { + "Authorization": f"Bearer {TOKEN}", + "Content-Type": "application/json", +} + +response = requests.post(HASS_URL, headers=headers, json=data) + +if response.status_code == 200: + print("Erfolgreich ausgeführt!") +else: + print(f"Fehler: {response.status_code}")