From df374337b691cf8cdff1a6370671018ca1b11e7e Mon Sep 17 00:00:00 2001 From: lucca Date: Mon, 29 Jun 2026 14:40:06 -0400 Subject: [PATCH] made script not use functions and instead execute by itself --- homeassistant/light.sh | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/homeassistant/light.sh b/homeassistant/light.sh index 9f9f849..49e26e2 100755 --- a/homeassistant/light.sh +++ b/homeassistant/light.sh @@ -1,25 +1,25 @@ -light() { - local entity="light.$1" +#!/bin/bash +source ~/sh/ha/.env +entity="light.$1" - if [[ $2 == "on" ]]; then - curl -X POST \ - -H "Authorization: Bearer $HA_APIKEY" \ - -H "Content-Type: application/json" \ - -d "{\"entity_id\":\"$entity\"}" \ - "$HA_URL/api/services/homeassistant/turn_on" +if [[ $2 == "on" ]]; then + curl -X POST \ + -H "Authorization: Bearer $HA_APIKEY" \ + -H "Content-Type: application/json" \ + -d "{\"entity_id\":\"$entity\"}" \ + "$HA_URL/api/services/homeassistant/turn_on" - elif [[ $2 == "off" ]]; then - curl -X POST \ - -H "Authorization: Bearer $HA_APIKEY" \ - -H "Content-Type: application/json" \ - -d "{\"entity_id\":\"$entity\"}" \ - "$HA_URL/api/services/homeassistant/turn_off" +elif [[ $2 == "off" ]]; then + curl -X POST \ + -H "Authorization: Bearer $HA_APIKEY" \ + -H "Content-Type: application/json" \ + -d "{\"entity_id\":\"$entity\"}" \ + "$HA_URL/api/services/homeassistant/turn_off" - else - curl -X POST \ - -H "Authorization: Bearer $HA_APIKEY" \ - -H "Content-Type: application/json" \ - -d "{\"entity_id\":\"$entity\",\"brightness_pct\":$2}" \ - "$HA_URL/api/services/light/turn_on" - fi -} +else + curl -X POST \ + -H "Authorization: Bearer $HA_APIKEY" \ + -H "Content-Type: application/json" \ + -d "{\"entity_id\":\"$entity\",\"brightness_pct\":$2}" \ + "$HA_URL/api/services/light/turn_on" +fi