From c22f51e7b087e1c1210004c9cddf22a05cfb4b06 Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Fri, 5 Dec 2025 22:41:48 +0100 Subject: [PATCH] HA payload fixed --- thinkcenter_monitor.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/thinkcenter_monitor.sh b/thinkcenter_monitor.sh index 0938892..e6ee867 100644 --- a/thinkcenter_monitor.sh +++ b/thinkcenter_monitor.sh @@ -44,13 +44,13 @@ trigger_power_cycle() { log "ALERT: Triggering power cycle for entity: $entity" - # Turn off - log "Sending turn_off request to Home Assistant..." - local response=$(curl -s -w "\n%{http_code}" -X POST \ - -H "Authorization: Bearer $HA_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"entity_id\": \"$entity\"}" \ - "$HA_URL/api/services/switch/turn_off") + # Turn off + log "Sending turn_off request to Home Assistant..." + local response=$(curl -s -w "\n%{http_code}" -X POST \ + -H "Authorization: Bearer $HA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"target\": {\"entity_id\": \"$entity\"}}" \ + "$HA_URL/api/services/switch/turn_off") local http_code=$(echo "$response" | tail -n 1) local body=$(echo "$response" | head -n -1) @@ -65,13 +65,13 @@ trigger_power_cycle() { log "Waiting 10 seconds before power-on..." sleep 10 - # Turn on - log "Sending turn_on request to Home Assistant..." - local response=$(curl -s -w "\n%{http_code}" -X POST \ - -H "Authorization: Bearer $HA_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"entity_id\": \"$entity\"}" \ - "$HA_URL/api/services/switch/turn_on") + # Turn on + log "Sending turn_on request to Home Assistant..." + local response=$(curl -s -w "\n%{http_code}" -X POST \ + -H "Authorization: Bearer $HA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"target\": {\"entity_id\": \"$entity\"}}" \ + "$HA_URL/api/services/switch/turn_on") local http_code=$(echo "$response" | tail -n 1) local body=$(echo "$response" | head -n -1)