Closed msanchezt closed 2 years ago
Hi,
You can use access_token
using this example:
# amazon-dash.yml
# ---------------
settings:
delay: 10
devices:
40:B4:CD:67:A2:E1:
name: Fairy
homeassistant: hassio.local
event: toggle_kitchen_light
access_token: YOUR_TOKEN
Replace 40:B4:CD:67:A2:E1
with your mac, hassio.local
with your home assistant local address and YOUR_TOKEN
using your token generated within your Home Assistant profile page.
I have not been able to personally verify this feature, but it should work.
Regards,
That didn't worked for me. Not clear what the "event" mean, as what I wanted is to trigger "services" (/api/services/) instead of events (/api/events).
I end up using this the API approach:
## Example of how to execute a url
# AC:63:BE:67:B2:F1:
# name: Kit Kat
# url: 'http://domain.com/path/to/webhook' # Url to execute
# method: post # HTTP method. By default GET
# headers: {"authorization": "key"}
# content-type: json # Only available if Body is defined
# body: '{"mac": "AC:63:BE:67:B2:F1", "action": "toggleLight"}' # Request payload. Remember the quotes
You can run a service using an event in Home Assistant.
You have info about events in the homeassistant documentation: https://www.home-assistant.io/docs/configuration/events/ https://www.home-assistant.io/docs/automation/trigger/
You can use any event name. Just use an event name in amazon-dash and create an automation in Homeassistant for your event.
Well.. a lot changed while writing this. Still My proposal would be: bring back Home Assistant Rest API support Creating a event and useing it as a trigger for an automation is in my opinon doing things in a roundabout way. Find it strange that you removed the direct api call out of amazon-dash. Even it worked very well in 1.2.0
For others stumble uppon this - Here is a sample config and automation calling a tts script and calling another when its already running. The documentaton has confused me a little
ab:cd:de:ef:8b:45:
name: swiffer 3
homeassistant: 10.0.0.27
event: event_dash_3min
access_token: eyJ0eXAi ( 183 in total ) 05TPHd$
automation:
- alias: Dashevent_3min
initial_state: 'on'
hide_entity: true
trigger:
- platform: event
event_type: event_dash_3min
action:
- service: script.turn_on
data_template:
entity_id: >-
{% if is_state("script.3min", "off") %}
script.3min
{% else %}
script.xmin
{% endif %}
´´´
Amazon-dash has never had support for other methods of the Home Assistant API than events. Maybe you're referring to the url executor:
http://docs.nekmo.org/amazon-dash/config_file.html#call-url
You can use this execution method if you prefer.
Jea, maybe. But its quite strange
Working on the Home assistant PI v1.2.0
aa:bb:cc:
name: Durex Timer 10
url: 'http://localhost:8123/api/services/script/turn_on'
method: post
headers: {"x-ha-access": "oldAPIpwd"}
content-type: json
body: '{"entity_id": "script.10min"}'
But not working on the seccond pi v1.3.1
aa:bb:cc:
name: Durex Timer 10
url: 'http://10.0.0.27:8123/api/services/script/turn_on'
method: POST
headers: {"x-ha-access": "oldAPIpwd"}
content-type: json
body: '{"entity_id": "script.10min"}'
I have tried to execute your command with both versions.
Amazon-dash v1.3.1:
POST /api/services/script/turn_on HTTP/1.1
Host: 127.0.0.1:8123
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
x-ha-access: oldAPIpwd
content-type: application/json
Content-Length: 29
{"entity_id": "script.10min"}
Amazon-dash v1.2.0:
POST /api/services/script/turn_on HTTP/1.1
Host: 127.0.0.1:8123
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
x-ha-access: oldAPIpwd
content-type: application/json
Content-Length: 29
{"entity_id": "script.10min"}
Both requests are exactly the same.
Closed due to inactivity.
Hi,
Anyone can point out how to use the "access_token" option for running commands in Home Assistant?
Thanks.