From 6dc2373e9cb193591e4fc827efd1946e448fc4fa Mon Sep 17 00:00:00 2001 From: lucca Date: Mon, 29 Jun 2026 14:38:02 -0400 Subject: [PATCH] added homeassistant light script --- homeassistant/light.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 homeassistant/light.sh diff --git a/homeassistant/light.sh b/homeassistant/light.sh new file mode 100755 index 0000000..9f9f849 --- /dev/null +++ b/homeassistant/light.sh @@ -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 +}