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

mqtt-scheduler

v1.0.1

Published

This is a node module / command line utility (depending on how you use it) to allow easier scheduling of "tasks" to be broadcasted on an MQTT network at a given time.

Downloads

3

Readme

mqtt-scheduler

This is a node module / command line utility (depending on how you use it) to allow easier scheduling of "tasks" to be broadcasted on an MQTT network at a given time.

Install

If you are installing this as a command line utility, use

npm install -g mqtt-scheduler

This will install the mqtt-scheduler globally and allow you to use it as a command line utility.

If you wish to use this as a module to access additional functionality, use

npm install --save mqtt-scheduler

within your node application.

The task file

The task file is used in either use-case. The file is a simple text file where each new line is a new task, and columns between tasks are single-tab delimited.

A typical file is:

garden lights		9am		garden/lights	on

This would create a task called lights, which would broadcast the topic "garden/lights" with the body of "on" every day at 9 am.

The columns for the file are as follows:

  1. Task name

  2. Time. Date.js is used internally for decent human language parsing of intervals/times.

  3. MQTT Topic

  4. Message payload

Command Line Usage

The simplest way to invoke mqtt-scheduler is passing both the host and file.

mqtt-scheduler --file pathToFile --host mqtt_host_address

CLI options/flags are:

  • -h / --host - Your MQTT host. Required.
  • -p / --port - Your MQTT port. Defaults to 1883, the MQTT default port.
  • -i / --id - Your MQTT client id - defaults to "mqtt_scheduler".
  • -u / --username - Your MQTT connection username, if required.
  • -P / --password - Your MQTT connection password, if required.
  • -f / --file - The path to the scheduled tasks file. Required.

Programmatic usage

const MQTTSCheduler = require('mqtt-scheduler');
var scheduler = new MQTTScheduler(opts, cb);

WHERE opts is an object with the following attributes:

  • host - Required - the address of your mqtt server
  • port - Defaults to 1883 - the port your mqtt server is listening on
  • clientId - defaults to mqtt_scheduler - the client id reported to the mqtt server
  • username - the username to log into the mqtt server (if required)
  • password - the password to log into the mqtt server (if requrired)
  • onConnect - function that is fired off when connection to the MQTT server occurs
  • onMessage - function that fires off when the client receives a message from the MQTT server
  • onError - function that is fired off when the MQTT client within the scheduler encounters an error
  • onClose - function that is fired off when the MQTT client connection closes
  • onTaskFire - function that is fired off when a task is triggered. It passes the task into the function

cb is an optional callback that will report an error or success of connection to the MQTT server.