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

@codekilo/signalk-trigger-event

v1.0.0

Published

A plugin to trigger events when a configurable condition is met

Downloads

18

Readme

SignalK event trigger plugin

This package is designed to allow other signalk plugins to receive notifications when certain values exceed a threshold.

configuration

The configuration for the plugin has two parts, first define the variables that are required for the expressions and then define the expressions and the events they trigger.

context

To create expressions you first have to define which signalk paths you will use and give them a short name: Each variable has two properties:

path

The signalk path, should include the vessel URN i.e. urn:mrn:imo:mmsi:244770688.navigation.speedOverGround.value The path can not be part of the notifications subtree since that tree is ignored by the plugin.

name

The name to give to this path in the expressions defined below i.e. sog

Trigger

for each trigger the following values are required:

condition

The condition that should trigger the event, uses jexl to evaluate the expression. The full signak tree for the specified vessel is available. The following expression would create an event when the vessel is going faster than 3 m/s : sog > 3

event

The name of the event that should be triggered when the condition is true.

trigger type

When to fire the event, has four available options

  • rising edge
    • only sends the event when the condition becomes true
  • falling edge
    • only sends the event when the condition becomes false
  • both edges
    • sends the event when the condition changes
  • for all deltas
    • send the event for all deltas while the conditon is true, including an event on the falling edge

use

After setting this plugin up, other plugins can use the configured events to trigger actions by listening to them.

The following example sets up a simple listener that will write to the plugins debug log

var unsubscribes = [];
module.exports = function(app) {
  var plugin = {};

  plugin.id = 'your-plugin';
  plugin.name = 'your plugin';
  plugin.description = 'A plugin to send notifications when an event occurs';

  plugin.start = function(options, restartPlugin) {
    let _notify = function(event) {
        app.debug(`Event received: ${event.event}, type: ${event.type}`);
    }
    app.on('eventName', _notify);
    unsubscribes.push(() => {
      eventEmitter.removeListener(event, _notify);
    });

    app.setProviderStatus('Running');
  };

   plugin.stop = function() {
    unsubscribes.forEach(f => f());
    app.setProviderStatus('Stopped');
  };
  return plugin;
}

Development

To install this package for development clone it from git and run npm link.

git clone https://github.com/codekilo/signalk-trigger.git
cd signalk-trigger
sudo npm link

Then go to the SignalK configuration directory (probably ~/.signalk) and link the module again:

$ cd .signalk 
$ npm link @codekilo/signalk-trigger-event