KhaosT / homebridge-amazondash

Amazon Dash Button plugin for Homebridge
58 stars 14 forks source link

More than one click recognised #9

Open sejoki opened 7 years ago

sejoki commented 7 years ago

I played around with the dash buttons and figured I could make them do more than one thing, not only depending on sunrise/sunset, but also if it was on/off. Since for me, the integration into home app doesn't seem to be working, I'm setting up my actions with Eve. I added two dummy switches, which are linked to a scene, so in theory, if I press the button and the switch is off, it triggers a scene and sets the switch to on. If I press it again and the switch is on, it triggers a different scene.

A great theory, there's one issue though, which is caused by the way the dash buttons work. It tries to enter the network more than once, hence more than one "click" is recognised. So if scene A is triggered to turn on one light and turn on the virtual button and scene B to turn of the light if the virtual button is on, it activates scene A and a couple of seconds later activates scene B, because the button is seemingly pressed again after the virtual switch has been set.

In node bin/findbutton I get the following:

Possible dash hardware address detected: ac:63:be:02:87:2e Manufacturer: Amazon Technologies Inc. Protocol: udp Possible dash hardware address detected: ac:63:be:02:87:2e Manufacturer: Amazon Technologies Inc. Protocol: udp Possible dash hardware address detected: ac:63:be:02:87:2e Manufacturer: Amazon Technologies Inc. Protocol: arp

Can you add some sort of a timeout that after the initial click, it ignores further clicks for 10-15 seconds?

kolossboss commented 7 years ago

I'm not sure what exactly do you want to do. Only switch a light on and off? For me the button only sends only one click and rhe follow works perfectly. And pls try to use the app Hesperus. Hesperus supported to Dash Button a way more better then Eve oder Home.app.

Try this:

Automation 1. If Dash pressed and switch off then switch on.

Automation 2. If Dash pressed and switch on then switch off.

sejoki commented 7 years ago

No, the issue isn't the setup of the automation rule. It's that every button click is recognised twice, which results in the rules cancelling each other.

The find button command shows two udp actions and one arp.

With the rules I have set up, the following happens: first button press -> automation 1, which turns my dummy switch ON and the corresponding lights as well. Everything fine so far. but then a second press is recognised (proven by the find button log), which triggers automation 2, since the dummy switch is turned ON.

The result is that the light turns on for about four seconds and then turns off again. It's basically putting itself in a loop because of that.

I tried Hesperus, it's more convenient for setting up rules, but it gives me the same result, as the issue isn't in any app but in the dash button itself, which apparently logs into my wifi twice. It's the same for both of my buttons, so I don't think I have a faulty one. The simple solution imo would be to only register the first button press, which can't be done in HomeKit, Eve or Hesperus.

marcodesantis71 commented 7 years ago

Hi

I don't understand how ti configure dash button on Hesperus.

Can you help me?

KhaosT commented 7 years ago

I'm not sure I understood your question? Are you asking about how to setup action for programmable switches in Hesperus or asking about "more than one click recognized"?

Sent from my iPhone

On Jan 26, 2017, at 12:37 PM, marcodesantis71 notifications@github.com wrote:

Hi

I don't understand how ti configure dash button on Hesperus.

Can you help me?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

marcodesantis71 commented 7 years ago

Ops

My problem is how ti setup action

KhaosT commented 7 years ago

Just open Hesperus -> Switch to Actions tab -> press add -> give it a name -> for the "If" part, pick the dash button you added, and select the pressed and then "add" -> at the "then" section select the scene you want to enable after pressing the button -> save

Sent from my iPhone

On Jan 26, 2017, at 12:44 PM, marcodesantis71 notifications@github.com wrote:

Ops

My problem is how ti setup action

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

marcodesantis71 commented 7 years ago

HI I followed your steps, but I continue to have a problem.

I attach my screen.

Where do I wrong? img_0257 img_0258 img_0259 img_0260

KhaosT commented 7 years ago

What is the problem you are experiencing? It looks right to me.

Sent from my iPhone

On Jan 26, 2017, at 1:15 PM, marcodesantis71 notifications@github.com wrote:

HI I followed your steps, but I continue to have a problem.

I attach my screen.

Where do I wrong?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

marcodesantis71 commented 7 years ago

On Hesperus app, if I press the icon nothing happens

KhaosT commented 7 years ago

Nothing should happen in the app. HomeKit should run the scene you selected when you pressed the button. If it doesn't, make sure you set the correct MAC address for your dash button.

Sent from my iPhone

On Jan 26, 2017, at 1:26 PM, marcodesantis71 notifications@github.com wrote:

On Hesperus app, if I press the icon nothing happens

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

DanBennettUK commented 7 years ago

I'm also having this issue. It seems like the latest Amazon Dash tries 5 times before giving up. Each try seems to be resolved as a click. So a timeout is required after the first click to ignore any more "clicks".

Did anyone manage to get this working as a On/Off switch? As for me, even using Hesperus, it performs both commands at the same time. And if using Hesperus I add an if statement (so if lights are off, turn them on) it just doesn't run at all.

KhaosT commented 7 years ago

Same as I said before, are you sure you used the right MAC address for the dash? For some routers I see the behavior that when you press the Dash Button, it also sent out a few ARP messages. So if you are not using the correct MAC address then it may trigger multiple times.

DanBennettUK commented 7 years ago

Certainly using the correct MAC, as it does trigger (and I see it trigger in Homekit). The problem is the multiple ARC messages the Dash sends causes a trigger each time.

KhaosT commented 7 years ago

Alright, give 0.0.4 a try?

DanBennettUK commented 7 years ago

Tried but no luck (whether that's HomeKit not updating the actions properly or not is another question).

What I've tried: In Hesperus I have 2 toggle actions. For on: If Dash= Pressed & Light 1 = off & Light 2 = off THEN turn both on. Vice versa for toggling off.

What I see when I have the Home app open is it switches to the Toggle On then to Toggle off rapidly.

KhaosT commented 7 years ago

Try run homebridge in debug mode (DEBUG=* homebridge) and post the log here after you click the button? I’d like to see if it’s the plugin posting multiple notifications or something else is doing this.

Best Wishes, Tian Zhang

On Mar 29, 2017, at 12:08 PM, Dan Bennett notifications@github.com wrote:

Tried but no luck (whether that's HomeKit not updating the actions properly or not is another question).

What I've tried: In Hesperus I have 2 toggle actions. For on: If Dash= Pressed & Light 1 = off & Light 2 = off THEN turn both on. Vice versa for toggling off.

What I see when I have the Home app open is it switches to the Toggle On then to Toggle off rapidly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/KhaosT/homebridge-amazondash/issues/9#issuecomment-290194075, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpU4Bkcv_VYWOMHx2U-d8swuXFXO3zfks5rqqwkgaJpZM4K7dln.

DanBennettUK commented 7 years ago

Not sure it's really giving any indication!

Output from as soon as I button press;

  EventedHTTPServer [::ffff:192.168.1.68] Sending HTTP event '16.9' with data: {"characteristics":[{"aid":16,"iid":9,"value":1}]} +8s
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '16.9' with data: {"characteristics":[{"aid":16,"iid":9,"value":1}]} +2ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP request: /characteristics +88ms
  HAPServer [CC:22:3D:E3:CE:89] HAP Request: PUT /characteristics +0ms
  Accessory [Homebridge Pi1] Processing characteristic set: [{"remote":true,"value":true,"aid":7,"iid":9},{"remote":true,"value":100,"aid":8,"iid":12},{"remote":true,"value":0,"aid":7,"iid":10},{"remote":true,"value":0,"aid":7,"iid":11},{"remote":true,"value":0,"aid":8,"iid":11},{"remote":true,"value":100,"aid":7,"iid":12},{"remote":true,"value":true,"aid":8,"iid":9},{"remote":true,"value":0,"aid":8,"iid":10}] +2ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value true +0ms
  Accessory [Homebridge Pi1] Setting Characteristic "Brightness" to value 100 +27ms
[3/29/2017, 7:19:06 PM] [Lamp] BRIGHTNESS: 100
  Accessory [Homebridge Pi1] Setting Characteristic "Hue" to value 0 +29ms
[3/29/2017, 7:19:06 PM] [Desk LEDs] HUE: 0
  Accessory [Homebridge Pi1] Setting Characteristic "Saturation" to value 0 +27ms
[3/29/2017, 7:19:06 PM] [Desk LEDs] SATURATION: 0
  Accessory [Homebridge Pi1] Setting Characteristic "Saturation" to value 0 +19ms
[3/29/2017, 7:19:06 PM] [Lamp] SATURATION: 0
  Accessory [Homebridge Pi1] Setting Characteristic "Brightness" to value 100 +25ms
[3/29/2017, 7:19:06 PM] [Desk LEDs] BRIGHTNESS: 100
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value true +31ms
  Accessory [Homebridge Pi1] Setting Characteristic "Hue" to value 0 +17ms
[3/29/2017, 7:19:06 PM] [Lamp] HUE: 0
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '8.9' notification for this connection since it originated here. +262ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '8.9' with data: {"characteristics":[{"aid":8,"iid":9,"value":true}]} +0ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '7.9' notification for this connection since it originated here. +847ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '7.9' with data: {"characteristics":[{"aid":7,"iid":9,"value":true}]} +0ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP Response is finished +1ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP request: /characteristics +100ms
  HAPServer [CC:22:3D:E3:CE:89] HAP Request: PUT /characteristics +1ms
  Accessory [Homebridge Pi1] Processing characteristic set: [{"remote":true,"value":0,"aid":7,"iid":9},{"remote":true,"value":false,"aid":8,"iid":9}] +0ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value 0 +1ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value false +14ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '7.9' notification for this connection since it originated here. +196ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '7.9' with data: {"characteristics":[{"aid":7,"iid":9,"value":0}]} +0ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '8.9' notification for this connection since it originated here. +7ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '8.9' with data: {"characteristics":[{"aid":8,"iid":9,"value":false}]} +1ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP Response is finished +1ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP request: /characteristics +7ms
  HAPServer [CC:22:3D:E3:CE:89] HAP Request: PUT /characteristics +0ms
  Accessory [Homebridge Pi1] Processing characteristic set: [{"remote":true,"value":false,"aid":8,"iid":9},{"remote":true,"value":false,"aid":7,"iid":9}] +1ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value false +0ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value false +14ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '7.9' notification for this connection since it originated here. +266ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '7.9' with data: {"characteristics":[{"aid":7,"iid":9,"value":false}]} +0ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP Response is finished +2ms

Interestingly no sign of it going "off" despite them going off... EDIT: Scrap that... Setting Characteristic "On" to value false

KhaosT commented 7 years ago

From the log we only sent one notification to inform HomeKit about value changes. Can you tell which device is 192.168.1.68 and which is 192.168.1.146?

DanBennettUK commented 7 years ago

192.168.1.68 is the Apple TV. 192.168.1.146 is my iPhone.

KhaosT commented 7 years ago

Is there by any chance you have other triggers that is triggered by power characteristic of the light? From the log it feels like the second off is triggered by something else instead of the programmable switch event.

DanBennettUK commented 7 years ago

The only triggers I have are based on location. Which I have off for testing this for that reason.

I've just noticed the triggers for toggling were appearing as disabled (even though it appeared to be toggling)... so I've re-enabled just in case and repost log... Sorry!

Doesn't really tell much a different story (I think somehow these are being cached when doing it via Hesperus.

Hesperus creates a scene for each toggle. And those are what are flipping each time. I'm hoping that is making sense to you because trying to bloody screen record is seemingly impossible now!

 EventedHTTPServer [::ffff:192.168.1.68] Sending HTTP event '16.9' with data: {"characteristics":[{"aid":16,"iid":9,"value":1}]} +8s
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '16.9' with data: {"characteristics":[{"aid":16,"iid":9,"value":1}]} +1ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP request: /characteristics +55ms
  HAPServer [CC:22:3D:E3:CE:89] HAP Request: PUT /characteristics +0ms
  Accessory [Homebridge Pi1] Processing characteristic set: [{"remote":true,"value":true,"aid":7,"iid":9},{"remote":true,"value":100,"aid":8,"iid":12},{"remote":true,"value":0,"aid":7,"iid":10},{"remote":true,"value":0,"aid":7,"iid":11},{"remote":true,"value":0,"aid":8,"iid":11},{"remote":true,"value":100,"aid":7,"iid":12},{"remote":true,"value":true,"aid":8,"iid":9},{"remote":true,"value":0,"aid":8,"iid":10}] +1ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value true +1ms
  Accessory [Homebridge Pi1] Setting Characteristic "Brightness" to value 100 +11ms
[3/29/2017, 7:30:04 PM] [Lamp] BRIGHTNESS: 100
  Accessory [Homebridge Pi1] Setting Characteristic "Hue" to value 0 +14ms
[3/29/2017, 7:30:04 PM] [Desk LEDs] HUE: 0
  Accessory [Homebridge Pi1] Setting Characteristic "Saturation" to value 0 +14ms
[3/29/2017, 7:30:04 PM] [Desk LEDs] SATURATION: 0
  Accessory [Homebridge Pi1] Setting Characteristic "Saturation" to value 0 +15ms
[3/29/2017, 7:30:04 PM] [Lamp] SATURATION: 0
  Accessory [Homebridge Pi1] Setting Characteristic "Brightness" to value 100 +15ms
[3/29/2017, 7:30:04 PM] [Desk LEDs] BRIGHTNESS: 100
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value true +39ms
  Accessory [Homebridge Pi1] Setting Characteristic "Hue" to value 0 +19ms
[3/29/2017, 7:30:04 PM] [Lamp] HUE: 0
  EventedHTTPServer [::ffff:192.168.1.68] HTTP Response is finished +359ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP request: /characteristics +7ms
  HAPServer [CC:22:3D:E3:CE:89] HAP Request: PUT /characteristics +1ms
  Accessory [Homebridge Pi1] Processing characteristic set: [{"remote":true,"value":0,"aid":7,"iid":9},{"remote":true,"value":false,"aid":8,"iid":9}] +0ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value 0 +1ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value false +11ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '7.9' notification for this connection since it originated here. +173ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '7.9' with data: {"characteristics":[{"aid":7,"iid":9,"value":0}]} +1ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '8.9' notification for this connection since it originated here. +25ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '8.9' with data: {"characteristics":[{"aid":8,"iid":9,"value":false}]} +1ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP Response is finished +4ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP request: /characteristics +8ms
  HAPServer [CC:22:3D:E3:CE:89] HAP Request: PUT /characteristics +0ms
  Accessory [Homebridge Pi1] Processing characteristic set: [{"remote":true,"value":false,"aid":8,"iid":9},{"remote":true,"value":false,"aid":7,"iid":9}] +1ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value false +0ms
  Accessory [Homebridge Pi1] Setting Characteristic "On" to value false +11ms
  EventedHTTPServer [::ffff:192.168.1.68] Muting event '7.9' notification for this connection since it originated here. +171ms
  EventedHTTPServer [::ffff:192.168.1.146] Sending HTTP event '7.9' with data: {"characteristics":[{"aid":7,"iid":9,"value":false}]} +0ms
  EventedHTTPServer [::ffff:192.168.1.68] HTTP Response is finished +1ms
DanBennettUK commented 7 years ago

https://www.youtube.com/watch?v=XeDSs0_2OiU finally... just to show I'm not mad more than anything xD

DanBennettUK commented 7 years ago

OK so I've left it 20 minutes to get a shower... come back and it's working flawlessly... so maybe your little patch has worked and HomeKit just hadn't updated the triggers from when they were last changed, or Homebridge was being silly buggers.

I'll keep an eye on this and update here in a while to confirm...

Caching? Hmm!

KhaosT commented 7 years ago

lol this is interesting… let me know if it occurs again.

DanBennettUK commented 7 years ago

Indeed. I have a sneaky suspicion of the Apple TV, as I know I had an issue in the past where it's seemingly cached a device that didn't exist for 24 hours... Will see! Thanks for being proactive though :D