Created
October 23, 2017 19:19
-
-
Save pschmitt/73c1e324bccf2ed75241b7e2c24fe89a to your computer and use it in GitHub Desktop.
Enable all automations on your HASS instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
enable_all_automations.sh HA_URL HA_PASSWORD