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

signalk-mqtt-bridge

v0.3.2

Published

SignalK Node server plugin that acts as a bridge between SignalK data and MQTT

Downloads

42

Readme

SignalK <> MQTT bridge

SignalK Node server plugin that acts as a bridge between SignalK data and MQTT. Its purpose is similar to the one of the signalk-mqtt-gw plugin, but this one has a different interaction with MQTT, inspired by Victron's dbus-mqtt module.

Note that this plugin doesn't have an embedded MQTT broker. It connects as a client to an MQTT broker running in the system or remotely.

Features

Scoped MQTT topics

All MQTT topics used by this plugin are prefixed with <action>/signalk/<systemId>/

  • <systemId> is the last section of the SignalK server uuid, e.g. 4881db477e55 from urn:mrn:signalk:uuid:2bb1928e-3118-415e-b242-4881db477e55. This is to avoid conflicts when more than one SignalK server is connected to the same MQTT broker
  • <action> defines the purpose of the topic, defined in the sections below
    • N: data sent from SignalK
    • R: read requests sent from MQTT clients to SignalK
    • W: deltas sent from MQTT clients to SignalK
    • P: PUT requests sent from MQTT clients to SignalK

When it connects to an MQTT broker, the plugin will publish two messages:

  • to topic N/signalk/<systemId>/keepalive with payload 1 to indicate that the keepalive mechanism is supported
  • to topic N/signalk/<systemId>/system/Serial with the <systemId> as payload

Keepalive

With the keepalive, MQTT clients can trigger the plugin to send all SignalK deltas or subscribe to deltas for specific paths.

To activate the keepalive, publish a message to topic R/signalk/<systemId>/keepalive. The payload may be blank, or may contain a JSON-encoded list of topics of interest. The keepalive will last for the configured TTL in the plugin config, 60 seconds by default. After that, the plugin will stop sending deltas until a new message is published to R/signalk/<systemId>/keepalive.

The topics of interest in the keepalive message follow the same notation as MQTT topic subscriptions. Any part of the topic-matching string can be replaced with a + to indicate a wildcard. The string may end with a # which indicates that all trailing parts are accepted.

For example, the following will instruct the plugin to send deltas for paths vessels.self.electrical.batteries.*.current and vessels.*.navigation.position.

mosquitto_pub -m '["vessels/self/electrical/batteries/+/current", "vessels/+/navigation/position"]' -t 'R/signalk/4881db477e55/keepalive'

An empty payload will instruct the plugin to send messages for all deltas.

mosquitto_pub -m '' -t 'R/signalk/4881db477e55/keepalive'

To keep the keepalive active all the time, you could use a command like this:

while :; do mosquitto_pub -m '' -t 'R/signalk/4881db477e55/keepalive'; sleep 30; done

Subscribe to SignalK deltas

This SignalK plugin sends deltas to MQTT using the N/ topic prefix. To receive deltas from SignalK, first subscribe to the topics of interest, then send periodic keepalive messages to keep the plugin active.

For example, use this to subscribe to deltas for all paths under vessels.self.*

mosquitto_sub -t 'N/signalk/4881db477e55/vessels/self/#'

# in a separate terminal
while :; do mosquitto_pub -m '["vessels/self/#"]' -t 'R/signalk/4881db477e55/keepalive'; sleep 30; done

Request SignalK data from MQTT

You can also request data from specific paths from SignalK, as a one-time request. To do so publish a message with the read topic prefix (R/...) with an empty payload. Remember to be subscribed to a matching topic to receive the data.

mosquitto_sub -t 'N/signalk/4881db477e55/vessels/self/#'

# in a separate terminal
mosquitto_pub -m '' -t 'R/signalk/4881db477e55/vessels/self/environment/depth/belowKeel'

Send deltas to SignalK via MQTT

To send deltas to SignalK via MQTT, publish a message with the W/ topic prefix, with the delta value as payload. For example:

mosquitto_pub -m '10' -t 'W/signalk/4881db477e55/vessels/self/environment/wind/speedApparent'

Send PUT requests to SignalK via MQTT

To send PUT requests to SignalK via MQTT, publish a message with the P/ topic prefix, with the PUT value as payload. For example:

mosquitto_pub -m '1' -t 'P/signalk/4881db477e55/vessels/self/electrical/switches/anchorLight/state'