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 🙏

© 2026 – Pkg Stats / Ryan Hefner

influx4mqtt

v2.0.1

Published

Record MQTT values in InfluxDB. Follows the mqtt-smarthome architecture.

Readme

influx4mqtt

mqtt-smarthome NPM version CI License

Record MQTT values in InfluxDB — the history behind a Grafana dashboard.

Subscribes to the topics you name, turns each message into one InfluxDB point and writes them in batches. Numeric values only: booleans and ON/OFF become 1/0, text is ignored, because a time series with a string in it is a series InfluxDB will not let you graph.

Built on mqtt-interfaces-core, so it has the same options, --install, <name>/info and maintenance topics as the rest of the xyz2mqtt fleet. Works with InfluxDB 1 and 2.

Install

npm install -g influx4mqtt
influx4mqtt --mqtt-url mqtt://broker                 # foreground
sudo influx4mqtt --install -n influx -u mqtt://broker   # systemd service influx4mqtt@influx

--install writes the options to /etc/influx4mqtt/<name>.env and enables influx4mqtt@<name>.service. Broker settings shared with the other adapters on the host live in /etc/mqtt-interfaces/broker.env.

Docker

Multi-arch image (amd64, arm64, armv7):

docker run -d --name influx4mqtt --restart unless-stopped \
  -e INFLUX4MQTT_MQTT_URL=mqtt://broker \
  -e INFLUX4MQTT_INFLUX_URL=http://influxdb:8086 \
  -e INFLUX4MQTT_SUBSCRIBE='+/status/#,$SYS/#' \
  ghcr.io/hobbyquaker/influx4mqtt

What gets recorded

Every message on a subscribed topic becomes one point:

| topic | payload | series | value | | -------------------------- | --------------------- | -------------------------- | --------------------------- | | hm/status/Licht/STATE | 21.5 | hm//Licht/STATE | 21.5 | | hm/status/Licht/STATE | {"val":21.5,"ts":…} | hm//Licht/STATE | 21.5 at the device's ts | | zigbee2mqtt/sensor/state | ON | zigbee2mqtt/sensor/state | 1 | | hm/status/mode | auto | — | not recorded |

  • The status level is collapsed: hm/status/lamp is recorded as hm//lamp, the mqtt-smarthome convention. --no-shorten-status records the full topic instead — but only do that on a fresh database, since it renames every series you already have.
  • {val, ts, lc} payloads are recorded at the device's own timestamp, not at arrival time.
  • Retained messages are ignored. On every reconnect the broker replays the retained value of every matching topic; recording those would pile duplicates at the reconnect time rather than when the value was measured.
  • $SYS/ is rewritten to $SYS/<hostname>/ by default, because $SYS topics are identical on every broker and two of them in one database would interleave into nonsense. --replace-sys chooses the prefix.

Options

| Option | Default | Meaning | | ------------------- | ----------------------- | ------------------------------------------------------- | | -s, --subscribe | +/status/# | topic to record, +/# wildcards; repeat for more | | -u, --mqtt-url | mqtt://localhost | broker url | | -n, --name | influx | instance name = topic prefix of its own topics | | --influx-url | http://127.0.0.1:8086 | InfluxDB base url | | --influx-version | 1 | 1 (/write?db=) or 2 (/api/v2/write, token auth) | | -d, --influx-db | mqtt | database (api 1) or bucket (api 2) | | --influx-org | | organisation (api 2) | | --influx-token | | api token (api 2; InfluxDB 1.8+ accepts it too) | | --influx-username | | http basic auth (api 1) | | --influx-password | | http basic auth (api 1) | | --shorten-status | true | record hm/status/lamp as hm//lamp | | --replace-sys | $SYS/<hostname>/ | rewrite the $SYS/ prefix | | --buf-length | 1000 | write once this many points are buffered | | --buf-interval | 30 | seconds between writes, however few points are buffered | | -v, --verbosity | info | error, warn, info, debug |

Every option is also an environment variable (INFLUX4MQTT_SUBSCRIBE, INFLUX4MQTT_INFLUX_URL, …); several subscriptions are comma separated there. --help lists the shared options too, and --config-schema prints the JSON Schema a management UI reads.

InfluxDB 2

influx4mqtt -u mqtt://broker \
  --influx-version 2 --influx-url http://influxdb:8086 \
  --influx-org home --influx-db mqtt --influx-token <token>

--influx-db is the bucket. Put the token in the instance's env file rather than on the command line, where a process list would show it — --install does that for you.

Topics of its own

| Topic | Meaning | | --------------------------------- | ---------------------------------------------------------------- | | <name>/connected | 2 InfluxDB is accepting writes · 1 broker only · 0 stopped | | <name>/info | endpoint, subscriptions, points recorded and skipped | | <name>/maintenance/set/loglevel | error | warn | info | debug at runtime | | <name>/maintenance/set/restart | graceful restart | | <name>/maintenance/stats | memory, cpu, event loop lag, uptime |

A database that is unreachable shows up as <name>/connected 1, so a broken recorder is visible without reading logs.

License

MIT © Sebastian Raff