Detect change in value of button

Hi all,

I have made several 20-button Zigbee controllers by DIYRuz. They use Zigbee tot send a MQTT signal.
Unlike other buttons they send the states of each individual button when you press one. Like so:

I push button 1:

zigbee2mqtt:info  2020-03-28 19:17:22: MQTT publish: topic 'zigbee2mqtt/0x00124b001f8347bc', payload '{"btn_17":true,"linkquality":111,"battery":38,"voltage":2438,"btn_1":false,"btn_5":true,"btn_13":true,"btn_9":true,"btn_18":true,"btn_10":true,"btn_6":true,"btn_7":true,"btn_14":true,"btn_19":true,"btn_15":true,"btn_2":true,"btn_16":true,"btn_8":true,"btn_3":true,"btn_11":true,"btn_12":true,"btn_20":false,"btn_4":true}'

I push button 1 again:

zigbee2mqtt:info  2020-03-28 19:17:30: MQTT publish: topic 'zigbee2mqtt/0x00124b001f8347bc', payload '{"btn_17":true,"linkquality":111,"battery":38,"voltage":2438,"btn_1":true,"btn_5":true,"btn_13":true,"btn_9":true,"btn_18":true,"btn_10":true,"btn_6":true,"btn_7":true,"btn_14":true,"btn_19":true,"btn_15":true,"btn_2":true,"btn_16":true,"btn_8":true,"btn_3":true,"btn_11":true,"btn_12":true,"btn_20":false,"btn_4":true}'

Any ideas what would be the best way to just detect a push of a button (I don’t need to track the state of individual buttons). I have tried the RBE function in NR, but it did not seem to work.

Assuming the only thing changing when a button is pressed is it’s value is being toggled true/false.

image

[{"id":"b6c03ba6.2a7ed8","type":"inject","z":"b4c78428.8b7a28","name":"btn_1: false","topic":"","payload":"{\"btn_17\":true,\"linkquality\":111,\"battery\":38,\"voltage\":2438,\"btn_1\":false,\"btn_5\":true,\"btn_13\":true,\"btn_9\":true,\"btn_18\":true,\"btn_10\":true,\"btn_6\":true,\"btn_7\":true,\"btn_14\":true,\"btn_19\":true,\"btn_15\":true,\"btn_2\":true,\"btn_16\":true,\"btn_8\":true,\"btn_3\":true,\"btn_11\":true,\"btn_12\":true,\"btn_20\":false,\"btn_4\":true}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":134,"y":544,"wires":[["40947373.13608c"]]},{"id":"8a5a7526.dff948","type":"inject","z":"b4c78428.8b7a28","name":"btn_1: true","topic":"","payload":"{\"btn_17\":true,\"linkquality\":111,\"battery\":38,\"voltage\":2438,\"btn_1\":true,\"btn_5\":true,\"btn_13\":true,\"btn_9\":true,\"btn_18\":true,\"btn_10\":true,\"btn_6\":true,\"btn_7\":true,\"btn_14\":true,\"btn_19\":true,\"btn_15\":true,\"btn_2\":true,\"btn_16\":true,\"btn_8\":true,\"btn_3\":true,\"btn_11\":true,\"btn_12\":true,\"btn_20\":false,\"btn_4\":true}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":124,"y":592,"wires":[["40947373.13608c"]]},{"id":"40947373.13608c","type":"function","z":"b4c78428.8b7a28","name":"","func":"const values = context.get(\"values\") || {}\nconst payload = msg.payload;\nmsg.payload = null;\n\nObject.keys(values).forEach(btn => {\n    if(values[btn] !== payload[btn]) {\n        msg.payload = btn;\n        return;\n    }\n})\ncontext.set(\"values\", payload);\n\n// No changes detected\nif(msg.payload === null) return;\n\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":544,"wires":[["b3fae7ed.844f28"]]},{"id":"b3fae7ed.844f28","type":"debug","z":"b4c78428.8b7a28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":438,"y":544,"wires":[]}]

Thank you @Kermit

I also asked in another thread, and this works great:

https://gathering.tweakers.net/forum/list_message/61926464#61926464