veonua / SmartThingsEdge-Xiaomi

SmartThings Edge drivers for XIaomi and Aqara devices
MIT License
67 stars 59 forks source link

Wall Switch (Double Rocker) both buttons pressed triggers also left and right button presses #15

Closed jpaju closed 1 year ago

jpaju commented 1 year ago

I have Aqara WXKG02LM_rev2 wall switch. When both buttons are pressed, the corresponding action is also triggered for left and right buttons, as well as for both buttons. This makes it hard to define routines/automations that are triggered by pressing both buttons, since routines registered to either left or right button are also triggered.

For example if there are three routines triggered by the same switch

  1. When left button is pressed, send notification "left"
  2. When right button is pressed, send notification "right"
  3. When both buttons are pressed, turn off a light

When pressing both buttons at the same time once the light is turned off, but both notifications ("left" and "right") are also sent.

Logs from smartthings-cli (with smartthings edge:drivers:logcat <driver-id>) confirm that in fact the driver emits event for each button press:

INFO Xiaomi/Aqara Switch and Button v1.9.1  <ZigbeeDevice: <device-id> [0x7D36] (<device-name>)> emitting event: {"attribute_id":"button","capability_id":"button","component_id":"group1","state":{"value":"pushed"},"state_change":true}
INFO Xiaomi/Aqara Switch and Button v1.9.1  <ZigbeeDevice: <device-id> [0x7D36] (<device-name>)> emitting event: {"attribute_id":"button","capability_id":"button","component_id":"main","state":{"value":"pushed"},"state_change":true}
INFO Xiaomi/Aqara Switch and Button v1.9.1  <ZigbeeDevice: <device-id> [0x7D36] (<device-name>)> emitting event: {"attribute_id":"button","capability_id":"button","component_id":"button2","state":{"value":"pushed"},"state_change":true}

The behavior is similar with other actions/button presses including both buttons (hold and double press), where corresponding action is also registered on left and right buttons.

Is this behaviour intended, or could it be changed so that pressing, holding, or double pressing both buttons would only emit event for the both button press, and not for left and right buttons?

veonua commented 1 year ago

This is intended behavior. It covers my most often use case: when one of the buttons is decoupled, and I want to turn off all the lights in the given room. I just press both buttons and the device doesn't send a button press for the decoupled button but sends only a group command.

While it's possible to set up routines to cover all the cases, I believe the current behavior is cleaner and more understandable for users.

If you can create a PR with settings that switch this behavior, I will merge it to the repo.