danimtb / dasshio

Hass.io add-on to easily use Amazon Dash Buttons with Home Assistant
Apache License 2.0
192 stars 63 forks source link

Some scripts work - others don't - here's how to fix it #106

Closed r1ch closed 2 years ago

r1ch commented 3 years ago

Great library; thank you! - I wanted to share some "oddness" that I've worked around - in case it's useful to others:

tl;dr

For any script, try using

domain: script
service: turn_on
service_data: '{"entity_id":"script.NAMEOFSCRIPTHERE"}'

I get the error "Unable to perform request: Check [url], [body], ...."

I'm using a script so I have (had...)

domain: script
service: name_of_script
service_data: '{}'

What is intriguing is that I can run the script alone, but if I get Dasshio to invoke it - it doesn't complete

Now, you can also (if you get a long lived token) excute the script how Dasshio will at your command line

curl -X POST  -H "Authorization: Bearer  long_lived_token"   -H "Content-Type: application/json"   http://homeassistant.local:8123/api/services/script/name_of_script

This hangs the duration for the delay in my script (I find that surprising, but... whatever!) Dasshio doesn't like that.

OK - so what to do - scriptception

curl -X POST  -H "Authorization: Bearer  long_lived_token"   -H "Content-Type: application/json"   http://homeassistant.local:8123/api/services/script/turn_on -d '{"entity_id":"script.name_of_script"}'

This asks to run a script very slightly less directly - but returns immediately Dasshio is happy. We are happy.

So great - how to turn that back into the config

domain: script
service: turn_on
service_data: '{"entity_id":"script.NAMEOFSCRIPTHERE"}'

Make sure you're using script.NAMEOFSCRIPT

r1ch commented 3 years ago

Updated readme as a PR in case you're interested https://github.com/danimtb/dasshio/pull/107

wspruce commented 2 years ago

Thank you so much! You saved my day.