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

Getting multiple triggers with one button push even with delay set at 60 #88

Closed bluepixel00 closed 4 years ago

bluepixel00 commented 5 years ago

At one point I had everything working but a month ago or so I noticed that any dash button push will trigger multiple events even if I have the delay set to 60. I am using the latest dash Hassio plugin and HA as of May 21, 2019.

Here is my log output from the dashio plugin: 2019-05-21 19:15:30,508 | INFO | Reading config file: /data/options.json 2019-05-21 19:15:30,509 | INFO | Starting... 2019-05-21 19:15:30,509 | INFO | Starting sniffing... 2019-05-21 19:15:44,460 | INFO | Random Request button pressed! 2019-05-21 19:15:44,915 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:44,915 | INFO | Status Code: 200 2019-05-21 19:15:44,915 | INFO | Successful request 2019-05-21 19:15:44,939 | INFO | Finishing sniffing 2019-05-21 19:15:44,940 | INFO | Starting sniffing... 2019-05-21 19:15:45,562 | INFO | Random Request button pressed! 2019-05-21 19:15:45,581 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:45,582 | INFO | Status Code: 200 2019-05-21 19:15:45,582 | INFO | Successful request 2019-05-21 19:15:45,595 | INFO | Finishing sniffing 2019-05-21 19:15:45,595 | INFO | Starting sniffing... 2019-05-21 19:15:47,083 | INFO | Random Request button pressed! 2019-05-21 19:15:47,104 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:47,104 | INFO | Status Code: 200 2019-05-21 19:15:47,104 | INFO | Successful request 2019-05-21 19:15:47,119 | INFO | Finishing sniffing 2019-05-21 19:15:47,119 | INFO | Starting sniffing... 2019-05-21 19:15:49,082 | INFO | Random Request button pressed! 2019-05-21 19:15:49,497 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:49,497 | INFO | Status Code: 200 2019-05-21 19:15:49,497 | INFO | Successful request 2019-05-21 19:15:49,515 | INFO | Finishing sniffing 2019-05-21 19:15:49,515 | INFO | Starting sniffing... 2019-05-21 19:15:50,531 | INFO | Random Request button pressed! 2019-05-21 19:15:50,551 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:50,551 | INFO | Status Code: 200 2019-05-21 19:15:50,551 | INFO | Successful request 2019-05-21 19:15:50,571 | INFO | Finishing sniffing 2019-05-21 19:15:50,571 | INFO | Starting sniffing... 2019-05-21 19:15:51,547 | INFO | Random Request button pressed! 2019-05-21 19:15:51,568 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:51,568 | INFO | Status Code: 200 2019-05-21 19:15:51,568 | INFO | Successful request 2019-05-21 19:15:51,595 | INFO | Finishing sniffing 2019-05-21 19:15:51,595 | INFO | Starting sniffing... 2019-05-21 19:15:52,740 | INFO | Random Request button pressed! 2019-05-21 19:15:52,762 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:52,762 | INFO | Status Code: 200 2019-05-21 19:15:52,762 | INFO | Successful request 2019-05-21 19:15:52,783 | INFO | Finishing sniffing 2019-05-21 19:15:52,783 | INFO | Starting sniffing... 2019-05-21 19:15:54,621 | INFO | Random Request button pressed! 2019-05-21 19:15:54,943 | INFO | Request: http://hassio/homeassistant/api/services/script/random_tts - body: {} 2019-05-21 19:15:54,943 | INFO | Status Code: 200 2019-05-21 19:15:54,943 | INFO | Successful request 2019-05-21 19:15:54,967 | INFO | Finishing sniffing 2019-05-21 19:15:54,967 | INFO | Starting sniffing...

bluepixel00 commented 5 years ago

This is occurring with 0.3.6 dashio and home assistant 0.93.2 but was working in a previous version of both dashio and home assistant. The only way I was able to remove the impact of this issue was by modifying my script to only run when it is not already running. This seems to have solved the repeated triggers from dashio. Is nobody else seeing this issue?

neilma1 commented 5 years ago

Yup - theres a few of us that reported it in issue #86 (admitedly the title isnt as explicit as yours :) Mind sharing the script? My buttons were set up originally to toggle a light. However I have had to modify mine to just switch the light off rather than toggle (however means I have turn the light on manually :)

What would the script look like?

bluepixel00 commented 5 years ago

Since I am using this button as a weather report I added a condition to see if the speaker is still playing and then added a delay at the end since each button press last for 20 seconds.

`weather_report: alias: Weather Report sequence:

bluepixel00 commented 5 years ago

In your case you could just prevent the script from running again with a similar condition and adding the delay.

neilma1 commented 5 years ago

Thank you! I have taken the weather idea and implemented that. Will work on changing my switches to follow the same process over next few days. Much appreciated!

bluepixel00 commented 5 years ago

Glad it works. I know it is a hack but at least it gets things running again. Prior to this change my weather report would keep restarting for the first 20 seconds and then finish so didn't make it very helpful. :)

bluepixel00 commented 5 years ago

For others wishing to implement this "hack" you would add something like the following to your script / automation. A script has an "off" or "on" state. "on" when it is actively running

condition: template value_template: "{{not is_state('script.your_script_name','on') }}"

Along with a delay at the end after the service is executed. delay: '00:0:15'

stavfx commented 5 years ago

I think that since #82 the timeout config is no longer being used

capstan1 commented 4 years ago

For others wishing to implement this "hack" you would add something like the following to your script / automation. A script has an "off" or "on" state. "on" when it is actively running

condition: template value_template: "{{not is_state('script.your_script_name','on') }}"

Along with a delay at the end after the service is executed. delay: '00:0:15'

Sorry fpr the noobish question, but could you give me an Example of a Script I could use for toggling a light?