npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mqtthook

v0.0.8

Published

It is a MQTT version of Webhook for IoT devices.

Downloads

23

Readme

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. Demo

The code of the MQTThook example:

var MQTThook = require('mqtthook');
var mqtthook = new MQTThook('mqtt://test.mosquitto.org');
mqtthook.hook('hooked-topic')
        .trigger(data => { console.log(`PM2.5: ${data.pm2_5} μg/m3`); });

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 = require('mqtthook');
var mqtthook = new 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.hook('hooked-topic')
        .if(data => { return data.pm2_5 > 70; })
        .trigger(data => { console.log(`PM2.5: ${data.pm2_5} μg/m3`); });

Trigger a WebHook which will store the data in a Google Sheets sheet when a hooked MQTT topic received PM2.5 data.

mqtthook.hook('hooked-topic').trigger('https://webhook.fake/hooks/3345678');

Trigger a MQTThook which will forward PM2.5 data to another MQTT topic when a hooked MQTT topic received the PM2.5 data.

mqtthook.hook('hooked-topic').trigger('triggered-topic');

Reference

  • MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.
  • Webhook in web development is a method of augmenting or altering the behavior of a web page, or web application, with custom callbacks.