made script not use functions and instead execute by itself

This commit is contained in:
lucca
2026-06-29 14:40:06 -04:00
parent 6dc2373e9c
commit df374337b6
+22 -22
View File
@@ -1,25 +1,25 @@
light() { #!/bin/bash
local entity="light.$1" source ~/sh/ha/.env
entity="light.$1"
if [[ $2 == "on" ]]; then if [[ $2 == "on" ]]; then
curl -X POST \ curl -X POST \
-H "Authorization: Bearer $HA_APIKEY" \ -H "Authorization: Bearer $HA_APIKEY" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"entity_id\":\"$entity\"}" \ -d "{\"entity_id\":\"$entity\"}" \
"$HA_URL/api/services/homeassistant/turn_on" "$HA_URL/api/services/homeassistant/turn_on"
elif [[ $2 == "off" ]]; then elif [[ $2 == "off" ]]; then
curl -X POST \ curl -X POST \
-H "Authorization: Bearer $HA_APIKEY" \ -H "Authorization: Bearer $HA_APIKEY" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"entity_id\":\"$entity\"}" \ -d "{\"entity_id\":\"$entity\"}" \
"$HA_URL/api/services/homeassistant/turn_off" "$HA_URL/api/services/homeassistant/turn_off"
else else
curl -X POST \ curl -X POST \
-H "Authorization: Bearer $HA_APIKEY" \ -H "Authorization: Bearer $HA_APIKEY" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"entity_id\":\"$entity\",\"brightness_pct\":$2}" \ -d "{\"entity_id\":\"$entity\",\"brightness_pct\":$2}" \
"$HA_URL/api/services/light/turn_on" "$HA_URL/api/services/light/turn_on"
fi fi
}