#!/bin/bash source ~/sh/ha/.env entity="switch.$1" case "$2" in on) service="turn_on" ;; off) service="turn_off" ;; *) echo "Usage: $0 {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"