added fan, light, and switch scripts for homeassistant
This commit is contained in:
Executable
+24
@@ -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"
|
||||
Reference in New Issue
Block a user