Files

25 lines
429 B
Bash
Executable File

#!/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"