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

Tags: #<Tag:0x00007f3262499df0> #<Tag:0x00007f3262499d00> #<Tag:0x00007f3262499bc0>

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.

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: