{"id":13341689,"url":"https://github.com/evanxd/mqtthook","last_synced_at":"2025-07-11T03:04:28.201Z","repository":{"id":57303757,"uuid":"85798314","full_name":"evanxd/mqtthook","owner":"evanxd","description":"It is a MQTT version of Webhook for IoT devices.","archived":false,"fork":false,"pushed_at":"2017-03-24T13:56:32.000Z","size":4573,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-20T06:08:40.170Z","etag":null,"topics":["internet-of-things","iot","mqtt","mqtthook","web-of-things","webhook","wot"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mqtthook","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evanxd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-22T07:32:43.000Z","updated_at":"2024-04-10T21:02:51.000Z","dependencies_parsed_at":"2022-08-24T17:10:19.106Z","dependency_job_id":null,"html_url":"https://github.com/evanxd/mqtthook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/evanxd/mqtthook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanxd%2Fmqtthook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanxd%2Fmqtthook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanxd%2Fmqtthook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanxd%2Fmqtthook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evanxd","download_url":"https://codeload.github.com/evanxd/mqtthook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanxd%2Fmqtthook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261050445,"owners_count":23102549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["internet-of-things","iot","mqtt","mqtthook","web-of-things","webhook","wot"],"created_at":"2024-07-29T19:25:43.248Z","updated_at":"2025-07-11T03:04:28.166Z","avatar_url":"https://github.com/evanxd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTThook\nIt is a npm module to setup MQTThooks ([MQTT][mqtt] version of [Webhook][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][ifttt], [Zapier][zapier], or others).\n\n## Try It\nGo to the [RunKit page][mqtthook-example] to setup an example MQTThook and use the [Websocket-based MQTT client][mqtt-client] or build a real [air quality monitoring station][air-quality-monitoring-station] to trigger it.\n![Demo](./images/demo.gif)\n\nThe code of the MQTThook example:\n```js\nvar MQTThook = require('mqtthook');\nvar mqtthook = new MQTThook('mqtt://test.mosquitto.org');\nmqtthook.hook('hooked-topic')\n        .trigger(data =\u003e { console.log(`PM2.5: ${data.pm2_5} μg/m3`); });\n```\n\nYou 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][mqtthook-example] will show the PM2.5 value you send to.\n\n## How-to\nInitialize a MQTThook instance.\n```js\nvar MQTThook = require('mqtthook');\nvar mqtthook = new MQTThook('mqtt://test.mosquitto.org');\n```\n\nTrigger a callback `function` to print the PM2.5 data on the console when a hooked MQTT topic received the data.\n```js\nmqtthook.hook('hooked-topic')\n        .if(data =\u003e { return data.pm2_5 \u003e 70; })\n        .trigger(data =\u003e { console.log(`PM2.5: ${data.pm2_5} μg/m3`); });\n```\n\nTrigger a [WebHook][webhook] which will store the data in a [Google Sheets][google-sheets] sheet when a hooked MQTT topic received PM2.5 data.\n```js\nmqtthook.hook('hooked-topic').trigger('https://webhook.fake/hooks/3345678');\n```\n\nTrigger a MQTThook which will forward PM2.5 data to another MQTT topic when a hooked MQTT topic received the PM2.5 data.\n```js\nmqtthook.hook('hooked-topic').trigger('triggered-topic');\n```\n\n## Reference\n- [MQTT][mqtt] is a machine-to-machine (M2M)/\"Internet of Things\" connectivity protocol.\n- [Webhook][webhook] in web development is a method of augmenting or altering the behavior of a web page, or web application, with custom callbacks.\n\n[webhook]: https://en.wikipedia.org/wiki/Webhook\n[mqtt]: http://mqtt.org\n[ifttt]: https://ifttt.com\n[zapier]: https://zapier.com\n[google-sheets]: https://www.google.com/intl/en/sheets/about/\n[mqtthook-example]: https://goo.gl/abgsTZ\n[mqtt-client]: http://www.hivemq.com/demos/websocket-client\n[air-quality-monitoring-station]: https://github.com/evanxd/air-quality-monitoring-station\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanxd%2Fmqtthook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevanxd%2Fmqtthook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanxd%2Fmqtthook/lists"}