[Zigbee2mqtt] Single click with Aqara Opple, two events in Home Assistant

Hello everybody !

Using home assistant and zigbee2mqtt for several months and very happy with it !
I have received my Aqara Opple (6 buttons) and paired it with my system, all good.

But I have noticed with Node Red, when I put a call to notification service on a single click of one of the Opple buttons, I am getting 2 notifications instead of one.

Here is the Zigbee2mqtt log when I click the button :

zigbee2mqtt:info  2020-05-02 15:59:14: MQTT publish: topic 'zigbee2mqtt/opple_6_buttons', payload '{"battery":100,"voltage":3113,"linkquality":99,"action":"button_6_single"}'
zigbee2mqtt:info  2020-05-02 15:59:14: MQTT publish: topic 'zigbee2mqtt/opple_6_buttons', payload '{"battery":100,"voltage":3113,"linkquality":99,"action":""}'
zigbee2mqtt:info  2020-05-02 15:59:14: MQTT publish: topic 'zigbee2mqtt/opple_6_buttons/action', payload 'button_6_single'

So apparently, the event “button_6_single” is sent two times in the mqtt topic.
I have put the value in config for homeassistant_legacy_triggers: false, thinking it would be related but sadly not.

My Zigbee2mqtt config :

data_path: /share/zigbee2mqtt
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.1.40:1883'
  user: *
  password: *
serial:
  port: /dev/ttyACM0
  disable_led: true
advanced:
  pan_id: 6754
  channel: 11
  network_key:
    - * .....
    - *
  availability_blacklist: []
ban: []
whitelist: []
queue: {}
socat:
  enabled: false
  master: 'pty,raw,echo=0,link=/dev/ttyZ2M,mode=777'
  slave: 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5'
  restartdelay: 1
  initialdelay: 1
  options: '-d -d'
  log: false
homeassistant_legacy_triggers: false

Does someone have an idea ? Is it normal behaviour ? Or should I fine tune my automations in Node Red ?

Thank you !

Set debounce on the device.

The event is sent twice but in different topics.
Seems like zigbee2mqtt/opple_6_buttons is providing the pushed and released , information.
zigbee2mqtt/opple_6_buttons/action seems to solely provide the pushed information.

Hello @Tinkerer,
I have tried to put the debounce in the global config of Zigbee2mqtt (in Home Assistant) but it doesn’t seem to be working (or I might have done it wrong, not sure about the process to go with home assistant addon of z2mqtt if I need to include it for a specific device like mine ?).

@eXtatic :
Yes that is what I saw too :slight_smile:
Here is the simplest node red configuration I could extract which produces the double event behavior :

And its source :

[
    {
        "id": "2318ab90.8cb604",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "b49ff4aa.84e158",
        "type": "api-call-service",
        "z": "2318ab90.8cb604",
        "name": "Notif",
        "server": "366a00db.0b1cd",
        "version": 1,
        "debugenabled": false,
        "service_domain": "notify",
        "service": "mobile_app_francoiss_iphone",
        "entityId": "",
        "data": "{\"title\":\"Bouton pressed\",\"message\":\"Number 6!\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 590,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "ca898adf.c16918",
        "type": "switch",
        "z": "2318ab90.8cb604",
        "name": "Which Button ?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "button_6_single",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 410,
        "y": 360,
        "wires": [
            [
                "b49ff4aa.84e158"
            ]
        ]
    },
    {
        "id": "e81dae2.20b575",
        "type": "trigger-state",
        "z": "2318ab90.8cb604",
        "name": "Aqara 6 Buttons",
        "server": "366a00db.0b1cd",
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityid": "sensor.opple_6_buttons_action",
        "entityidfiltertype": "exact",
        "debugenabled": false,
        "constraints": [],
        "constraintsmustmatch": "all",
        "outputs": 2,
        "customoutputs": [],
        "outputinitially": false,
        "state_type": "str",
        "x": 200,
        "y": 360,
        "wires": [
            [
                "ca898adf.c16918"
            ],
            []
        ]
    },
    {
        "id": "366a00db.0b1cd",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]

I suspect that there is something to fine tune in the rule of the switch. Would it make sense ? :slight_smile:

Hello, I am new
with which program the graphics were made
?

Quite a bit new here too, but I think you’re wrong with the “graphics”
Its NodeRed I think, a system who in turn can be used to manage Home Assistant devices outside Home Assistant, make rules and alike.
Look further into that if you’re interested.
My two cents…

Did you figure out what was happening? I’m now seeing the same thing.

Unfortunately not.
In the “devices.yaml” file I tried to put this :

'0x04cf8cdf3c77b6a1':
  friendly_name: opple_6_buttons
  debounce: 0.5

But still am getting twice the service called.

1 Like

Had the same problem of press and release event with same ID. So I made something in node-red.

Here is the code you can import in node-red:

[{"id":"834c5c8e.8cfde","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"7a891c5b.328e74","type":"switch","z":"834c5c8e.8cfde","name":"Light Switches","property":"payload.event.id","propertyType":"msg","rules":[{"t":"eq","v":"switch_7","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":460,"wires":[["883999d9.0762b8"]]},{"id":"275dd03e.5f90f","type":"server-events","z":"834c5c8e.8cfde","name":"All Events","server":"58a005eb.3ee49c","event_type":"deconz_event","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":80,"y":460,"wires":[["9ff872a8.70fa2"]]},{"id":"883999d9.0762b8","type":"switch","z":"834c5c8e.8cfde","name":"Click Type","property":"payload.event.event","propertyType":"msg","rules":[{"t":"eq","v":"1002","vt":"str"},{"t":"eq","v":"2002","vt":"str"},{"t":"eq","v":"3002","vt":"str"},{"t":"eq","v":"4002","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":590,"y":460,"wires":[["253cb10a.dffd3e"],["e6ef7756.582328"],["96e97818.9f58c8"],["46d10a85.303be4"]]},{"id":"96e97818.9f58c8","type":"api-call-service","z":"834c5c8e.8cfde","name":"woonkamer versterker","server":"58a005eb.3ee49c","version":1,"debugenabled":true,"service_domain":"switch","service":"toggle","entityId":"switch.on_off_plug_in_unit_6","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":820,"y":480,"wires":[[]]},{"id":"9ff872a8.70fa2","type":"delay","z":"834c5c8e.8cfde","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":240,"y":460,"wires":[["7a891c5b.328e74"]]},{"id":"46d10a85.303be4","type":"api-call-service","z":"834c5c8e.8cfde","name":"woonkamer dim lamp","server":"58a005eb.3ee49c","version":1,"debugenabled":true,"service_domain":"light","service":"toggle","entityId":"light.color_temperature_light_2","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":820,"y":540,"wires":[[]]},{"id":"e6ef7756.582328","type":"api-call-service","z":"834c5c8e.8cfde","name":"woonkamer cement","server":"58a005eb.3ee49c","version":1,"debugenabled":true,"service_domain":"switch","service":"toggle","entityId":"switch.cement","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":810,"y":420,"wires":[[]]},{"id":"253cb10a.dffd3e","type":"api-call-service","z":"834c5c8e.8cfde","name":"woonkamer spotjes","server":"58a005eb.3ee49c","version":1,"debugenabled":true,"service_domain":"switch","service":"toggle","entityId":"switch.spotjes","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":810,"y":360,"wires":[[]]},{"id":"58a005eb.3ee49c","type":"server","name":"Home Assistant"}]
1 Like

Thank you ! I have implemented the limit block in my flows, I will test it when I come back home :slight_smile:

i have also a Opple, but will not work.

i press a button, and after 0.1seconds the lights goes off.
i try this with a limit node, but after this, i cant switch off my lights.

[{"id":"e34f2df7.ff9ed","type":"tab","label":"Partyraum","disabled":false,"info":""},{"id":"4094bc62.58ae14","type":"trigger-state","z":"e34f2df7.ff9ed","name":"Taster","server":"366a00db.0b1cd","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.partyraum_schalter_action","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":90,"y":100,"wires":[["f0af87b0.d580e8"],[]]},{"id":"6933455a.cfd5ec","type":"api-call-service","z":"e34f2df7.ff9ed","name":"Light on","server":"d635031d.ddc2a","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.partyraum_kicker","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":360,"wires":[[]]},{"id":"5147e0f1.eb25b","type":"toggle","z":"e34f2df7.ff9ed","name":"","onOffTopic":"","onValue":"on","onType":"str","offValue":"off","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"ifChanged","x":520,"y":360,"wires":[["4f591e40.19d1b"]]},{"id":"4f591e40.19d1b","type":"switch","z":"e34f2df7.ff9ed","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":360,"wires":[["6933455a.cfd5ec"],["8366d853.4f0708"]]},{"id":"8366d853.4f0708","type":"api-call-service","z":"e34f2df7.ff9ed","name":"Light off","server":"d635031d.ddc2a","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.partyraum_kicker","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":420,"wires":[[]]},{"id":"1eebbdbc.05b2a2","type":"api-call-service","z":"e34f2df7.ff9ed","name":"Light on","server":"d635031d.ddc2a","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.partyraum_dartscheibe","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":240,"wires":[[]]},{"id":"ed0df7a0.8868a8","type":"toggle","z":"e34f2df7.ff9ed","name":"","onOffTopic":"","onValue":"on","onType":"str","offValue":"off","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"ifChanged","x":520,"y":240,"wires":[["a525b9.bebeaa48"]]},{"id":"a525b9.bebeaa48","type":"switch","z":"e34f2df7.ff9ed","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":240,"wires":[["1eebbdbc.05b2a2"],["48f73ef4.01258"]]},{"id":"48f73ef4.01258","type":"api-call-service","z":"e34f2df7.ff9ed","name":"Light off","server":"d635031d.ddc2a","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.partyraum_dartscheibe","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":300,"wires":[[]]},{"id":"c070fb10.8517c8","type":"api-call-service","z":"e34f2df7.ff9ed","name":"Light on","server":"d635031d.ddc2a","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.partyraum_theke","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":120,"wires":[[]]},{"id":"e8bc70c0.8f263","type":"toggle","z":"e34f2df7.ff9ed","name":"","onOffTopic":"","onValue":"on","onType":"str","offValue":"off","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"ifChanged","x":520,"y":120,"wires":[["db467386.cfcb1"]]},{"id":"f0af87b0.d580e8","type":"switch","z":"e34f2df7.ff9ed","name":"Taster gedrĂĽckt","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"button_1_single","vt":"str"},{"t":"eq","v":"button_2_single","vt":"str"},{"t":"eq","v":"button_3_single","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":260,"y":100,"wires":[["e8bc70c0.8f263"],["ed0df7a0.8868a8"],["5147e0f1.eb25b"]]},{"id":"db467386.cfcb1","type":"switch","z":"e34f2df7.ff9ed","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":120,"wires":[["c070fb10.8517c8"],["1f818269.b145ae"]]},{"id":"1f818269.b145ae","type":"api-call-service","z":"e34f2df7.ff9ed","name":"Light off","server":"d635031d.ddc2a","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.partyraum_theke","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":180,"wires":[[]]},{"id":"d7a791bd.79454","type":"comment","z":"e34f2df7.ff9ed","name":"Theke","info":"","x":510,"y":80,"wires":[]},{"id":"d6166876.7ca918","type":"comment","z":"e34f2df7.ff9ed","name":"Dart","info":"","x":510,"y":200,"wires":[]},{"id":"63237717.d107e8","type":"comment","z":"e34f2df7.ff9ed","name":"Kicker","info":"","x":510,"y":320,"wires":[]},{"id":"366a00db.0b1cd","type":"server","name":"Home Assistant"},{"id":"d635031d.ddc2a","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]