Execute linux command on zigbee device event

Hi,

Is it possible to execute some linux command when the event occurs… for example… I want to send mail when the switch is OFF/ON or something like that…

Thank you,
M

You could do this with Node Red listening on MQTT zigbee2mqtt/[DEVICE_NAME] and putting a switch node after the MQTT so you can connect an email node on the 2 switch (ON/OFF) exit node.
Here an example:

[{"id":"42c1b465.8cd31c","type":"mqtt in","z":"80e30193.68b348","name":"","topic":"zigbee2mqtt/[YOUR-DEVICE-FRIENDLY-NAME]","qos":"2","datatype":"auto","broker":"8b6459a5.4a6a6","x":220,"y":580,"wires":[["a008cc3b.99e4d8"]]},{"id":"70b4e895.cd7d7","type":"switch","z":"80e30193.68b348","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":630,"y":580,"wires":[["9be14b98.daef2"],["f75828e3.00983"]]},{"id":"a008cc3b.99e4d8","type":"json","z":"80e30193.68b348","name":"","property":"payload","action":"","pretty":false,"x":490,"y":580,"wires":[["70b4e895.cd7d7"]]},{"id":"9be14b98.daef2","type":"change","z":"80e30193.68b348","name":"","rules":[{"t":"set","p":"to","pt":"msg","to":"your-email@address.com","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Switch status","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"The switch is now in ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":560,"wires":[["fe0397d7.a0678"]]},{"id":"fe0397d7.a0678","type":"e-mail","z":"80e30193.68b348","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"","x":990,"y":580,"wires":[]},{"id":"f75828e3.00983","type":"change","z":"80e30193.68b348","name":"","rules":[{"t":"set","p":"to","pt":"msg","to":"your-email@address.com","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Switch status","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"The switch is now in OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":600,"wires":[["fe0397d7.a0678"]]},{"id":"8b6459a5.4a6a6","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

P.s. You have to install the email node “node-red-node-email” from the “manage palette” - “install”

Hi andrex,
thanks for the tip… I mentioned email just as an example…
I managed to listen to MQTT trafic using Mosquitto-PHP library… and do exactly what I wanted… and kind of program logic which can do anything uppon some MQTT event occurs…

M