MQTThook
It is a npm module to setup MQTThooks (MQTT version of Webhook) for IoT devices. It helps MQTT-based IoT devices interact with real-world Web applications/services easier and faster with automation services (e.g. IFTTT, Zapier, or others).
Try It
Go to the RunKit page to setup an example MQTThook and use the Websocket-based MQTT client or build a real air quality monitoring station to trigger it.
The code of the MQTThook example:
var MQTThook = ;var mqtthook = 'mqtt://test.mosquitto.org';mqtthook ;
You can send a JSON data with the format { "pm2_5": 17 }
to the hooked-topic
topic on the mqtt://test.mosquitto.org
broker to trigger the MQTThook. The RunKit page will show the PM2.5 value you send to.
How-to
Initialize a MQTThook instance.
var MQTThook = ;var mqtthook = 'mqtt://test.mosquitto.org';
Trigger a callback function
to print the PM2.5 data on the console when a hooked MQTT topic received the data.
mqtthook ;
Trigger a WebHook which will store the data in a Google Sheets sheet when a hooked MQTT topic received PM2.5 data.
mqtthook;
Trigger a MQTThook which will forward PM2.5 data to another MQTT topic when a hooked MQTT topic received the PM2.5 data.
mqtthook;