added fan, light, and switch scripts for homeassistant

This commit is contained in:
lucca
2026-06-29 14:54:33 -04:00
parent df374337b6
commit f346c5cdf1
2 changed files with 64 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
source ~/sh/ha/.env
entity="switch.$1"
case "$2" in
on)
service="turn_on"
;;
off)
service="turn_off"
;;
*)
echo "Usage: $0 <switch_name> {on|off}"
exit 1
;;
esac
curl -X POST \
-H "Authorization: Bearer $HA_APIKEY" \
-H "Content-Type: application/json" \
-d "{\"entity_id\":\"$entity\"}" \
"$HA_URL/api/services/switch/$service"