added homeassistant light script

This commit is contained in:
lucca
2026-06-29 14:38:02 -04:00
parent a151be6dfe
commit 6dc2373e9c
+25
View File
@@ -0,0 +1,25 @@
light() {
local 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"
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
}