1
0

sync_to_alexa.sh 767 B

12345678910111213141516171819
  1. #!/bin/sh
  2. # Read entity registry from storage
  3. TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhNTk3MGM3YTQxNTE0YjZhYjg1OTNjZjJjMWY2NGQ0MyIsImlhdCI6MTc2NzI1OTE1MCwiZXhwIjoyMDgyNjE5MTUwfQ.hjng9QODqQsGLly3OXCKp7f5CPM6XcpgRLztVnPynTU"
  4. # Parse entity registry and expose each entity
  5. cat /homeassistant/.storage/core.entity_registry | \
  6. grep -B2 '"should_expose":true' | \
  7. grep '"entity_id"' | \
  8. cut -d'"' -f4 | \
  9. while read entity; do
  10. if [ ! -z "$entity" ]; then
  11. wget -q -O- --post-data="{\"entity_id\":\"$entity\",\"assistants\":[\"alexa\"]}" \
  12. --header="Authorization: Bearer $TOKEN" \
  13. --header="Content-Type: application/json" \
  14. http://localhost:8123/api/services/homeassistant/expose_entity
  15. echo "Exposed: $entity"
  16. fi
  17. done