It is a MQTT version of Webhook for IoT devices. It helps MQTT-based IoT devices use automation services (e.g. IFTTT or Zapier) to interact with existed Web applications/services and enrich its capability.
Initialize a MQTThook instance.
var MQTThook = require('mqtthook');
var mqtthook = new MQTThook('mqtt://test.mosquitto.org');
Trigger a WebHook which will do some automation things when a hooked MQTT topic received real-time PM2.5 data.
mqtthook.hook('hooked-topic').trigger('https://webhooks.evanxd.io/hooks/3345678', { pm2_5: 'pm2_5' });
Trigger a function
to print the real-time PM2.5 data on the console when a hooked MQTT topic received the data.
mqtthook.hook('hooked-topic').trigger((data) => { console.log(`PM2.5: ${data.pm2_5}`); });
- MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.