Fresh start - excluded large ROM JSON files
This commit is contained in:
27
skills/home-assistant/scripts/ha-api.sh
Normal file
27
skills/home-assistant/scripts/ha-api.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Home Assistant API helper script
|
||||
# Usage: ./ha-api.sh <endpoint> [method] [body]
|
||||
|
||||
HA_URL="${HA_URL:-http://localhost:8123}"
|
||||
HA_TOKEN="${HA_TOKEN:-}"
|
||||
|
||||
if [ -z "$HA_TOKEN" ]; then
|
||||
echo "Error: HA_TOKEN not set. Export HA_TOKEN first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ENDPOINT="$1"
|
||||
METHOD="${2:-GET}"
|
||||
BODY="${3:-}"
|
||||
|
||||
if [ -n "$BODY" ]; then
|
||||
curl -s -X "$METHOD" \
|
||||
-H "Authorization: Bearer $HA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$BODY" \
|
||||
"$HA_URL$ENDPOINT"
|
||||
else
|
||||
curl -s -X "$METHOD" \
|
||||
-H "Authorization: Bearer $HA_TOKEN" \
|
||||
"$HA_URL$ENDPOINT"
|
||||
fi
|
||||
Reference in New Issue
Block a user