Skip to content

Instantly share code, notes, and snippets.

@pschmitt
Created October 23, 2017 19:19
Show Gist options
  • Select an option

  • Save pschmitt/73c1e324bccf2ed75241b7e2c24fe89a to your computer and use it in GitHub Desktop.

Select an option

Save pschmitt/73c1e324bccf2ed75241b7e2c24fe89a to your computer and use it in GitHub Desktop.
Enable all automations on your HASS instance
#!/usr/bin/env bash
HA_URL="$1"
HA_PASSWORD="$2"
_api_call() {
if [[ -n "$3" ]]
then # WITH DATA
curl -qs -X "$1" \
-H "x-ha-access: $HA_PASSWORD" \
-H "Content-Type: application/json" \
-d "$3" \
"${HA_URL}/api/${2}"
else # NO DATA
curl -qs -X "$1" \
-H "x-ha-access: $HA_PASSWORD" \
-H "Content-Type: application/json" \
"${HA_URL}/api/${2}"
fi
}
enable_entity() {
_api_call POST services/homeassistant/turn_on \
'{"entity_id": "'$1'"}'
}
list_automations() {
_api_call GET states | jq -r '.[].entity_id' | grep '^automation.'
}
for a in $(list_automations)
do
echo
enable_entity "$a"
done
@pschmitt

pschmitt commented Oct 23, 2017

Copy link
Copy Markdown
Author

Usage: enable_all_automations.sh HA_URL HA_PASSWORD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment