Nekmo / amazon-dash

Hack your Amazon Dash to run what you want.
MIT License
826 stars 69 forks source link

Integration with home assistant: 1st press doesn't send event to home assistant. 2th press ok. #144

Closed Metus88 closed 3 years ago

Metus88 commented 5 years ago

What is the purpose of your issue?

Description

The tool works great. But sometimes the first time that it runs home assistant doesn't receive the event. If I press again the bottom it works. If I wait 1 hour (and I press the button) it's work again at the first pressed. But after 24hr if I press 1 time the button home assistant doesn't receive the trigger event. I use authentication with "Long-Lived Access Tokens"

What I Did

I used telegram notification inside amazon-dash.yml so I understood that when I press the button (also the first time) the amazon-dash tool works and I receive the telegram notification so the problem is only the event that is not received from home assistant (or send by amazon-dash).

Maybe there is some timeout during the authentication process that stop the first event. maybe can I try a workaround sending 2 events? Is it possible to send more that one event to home assistant? I was thinking -send 1st event -wait -send 2th event (same of the 1st one)

Am I the only one to have this problem?

I used the dush button as doorbell so I prefer to be sure to receive the event trigger in home assistant, recording camera etc...etc..

amazon-dash.yml

B4:7C:XX:XX:XX:XX: name: Dash button
homeassistant: http://192.168.1.XXX:8123
access_token: XXXXXXXXXXXXXXX event: dash_pressed

automation.yaml

Nekmo commented 5 years ago

These failures are usually due to network issues. My recommendation is to debug using discovery mode.

Metus88 commented 5 years ago

update. I found this in /var/log/syslog "Sep 26 09:45:11 fotovoltaico systemd[1]: Configuration file /lib/systemd/system/amazon-dash.service is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway."

I opened the file amazon-dash.service: ` [Unit] Description=Amazon Dash service After=network-online.target Wants=network-online.target

[Service] User=root ExecStart=/usr/bin/env amazon-dash run --config /etc/amazon-dash.yml Restart=always RestartSec=3

[Install] WantedBy=multi-user.target ` Can it help?

Metus88 commented 4 years ago

Update: I bought a raspberry pi 4 and I used the same sd card. And it works perfectly. Update 2: If I use the command: top I see this:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  604 root      20   0   53544  36824   9072 R 100.0   0.9 849:31.47 amazon-dash
  655 homeass+  20   0  934940 207484  38876 S  15.9   5.2 154:43.74 hass

amazon-dash use 100% CPU all the time! (94% or more) Do you have the same? If I disabled it, it disappears sudo systemctl stop amazon-dash But when I start it again, the same 100% CPU Thanks

Nekmo commented 4 years ago

I don't have a Raspberry PI 4 but in 3b+ model use 15-30% CPU. How do you connect your raspberry pi to the network?

Metus88 commented 4 years ago

Wifi. Why this question?