{"_id":"@codekilo/signalk-trigger-event","_rev":"1-85fca931bdc1a74cdbe286951e312520","name":"@codekilo/signalk-trigger-event","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@codekilo/signalk-trigger-event","version":"1.0.0","description":"A plugin to trigger events when a configurable condition is met","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/codekilo/signalk-trigger.git"},"keywords":["signalk-node-server-plugin"],"author":{"name":"Albert Smit","email":"albertsmit93@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/codekilo/signalk-trigger/issues"},"dependencies":{"jexl":"^2.2.2","lodash":"^4.17.15"},"homepage":"https://github.com/codekilo/signalk-trigger#readme","devDependencies":{"chai":"^4.2.0","mocha":"^8.0.1"},"gitHead":"20841ac85e890934a65f16f28b2c34df5b9a956c","_id":"@codekilo/signalk-trigger-event@1.0.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-b/FVpr9qJM5PeMB04x49hUdrkpUyOxfrnpqJnLLlKr1n3vVevDts6F93T9R3giAX3X/s8R9N+iGyc53/I6zNEQ==","shasum":"1ba0f7da7081900ba718db6b999a740c263a8606","tarball":"https://registry.npmjs.org/@codekilo/signalk-trigger-event/-/signalk-trigger-event-1.0.0.tgz","fileCount":5,"unpackedSize":12366,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6f+uCRA9TVsSAnZWagAAAD4P/jjRAoXBbtaLyC7bJYq9\nTAxOGSEg/Nk7vP2d9uByPhI6QYDLknFlKSM15JQC0lswDK88UHCiCKN7cHIu\nlhSoNDAgDEO+zKeuubwuJ1HLlUIn8bzIyE27emgu1oLJ5ORq5KOrlZHLn9Ls\n7NnlJjAfBUZGsDsaAW1JoASMeyDCNz1Gw9KPFuyds0Wj4aZC2WEwLrmXIJhQ\nrtHVrGlQEg6O7GTwF45KpUcOFKF74KCiHawHuwpohHmA+aTZUsIxXBKtJYG+\nZprqxIzsm7cAnqA3nfQ3I3NuKlDL3dTm0Zw0oWkWlNbBDgJ1tiA9R6rBUyLd\n7yFp5obkNp/je4khCpH6/xKESQ4TFNW7g2SAnB64l+eSi4rt3gqxS0Cv2Xso\njxhyxfycLYDxFL9rfuVf50DuKSoHiZ+AXgEaDErDPyazL1TWBo2uFGfnXGhv\nqjohQ7cZNxD9aPek2ct/5g++SFNq7F8IzZg61d+Ld4xI4L9M8JQVHaVOswBl\nsht303T7TRvANTfVJ19keIE3VIO3m3W8x1yCuSoNza1HqYu0jRt/ja6plNVJ\ntXB9ZnML1DfThMVoV1w88d+l4vMHDJhSBuGvrR6vfHlNQCeiVfADkSrUMJjG\n9CADf0/OWSceQPRS90dIS1zcBhqvsGRkJTgYaSjH4pFMFOkX2OW5QwaANNPw\nf3aw\r\n=0Owj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGx3NsIQRThsXv7s6D8v1EAlSuPeYtmBEp2RtK5ob8BAIhAMnj0oudQBS3/1+2B54bTBfvIv9DIEWHLV8XWXNWdrPt"}]},"maintainers":[{"name":"albert-smit","email":"albertsmit93@gmail.com"},{"name":"munnik","email":"martijndemunnik@protonmail.com"}],"_npmUser":{"name":"albert-smit","email":"albertsmit93@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/signalk-trigger-event_1.0.0_1592393646055_0.9818280532852361"},"_hasShrinkwrap":false}},"time":{"created":"2020-06-17T11:34:05.806Z","1.0.0":"2020-06-17T11:34:06.146Z","modified":"2022-04-05T00:03:11.565Z"},"maintainers":[{"name":"albert-smit","email":"albertsmit93@gmail.com"},{"name":"munnik","email":"martijndemunnik@protonmail.com"}],"description":"A plugin to trigger events when a configurable condition is met","homepage":"https://github.com/codekilo/signalk-trigger#readme","keywords":["signalk-node-server-plugin"],"repository":{"type":"git","url":"git+https://github.com/codekilo/signalk-trigger.git"},"author":{"name":"Albert Smit","email":"albertsmit93@gmail.com"},"bugs":{"url":"https://github.com/codekilo/signalk-trigger/issues"},"license":"MIT","readme":"# SignalK event trigger plugin\n\nThis package is designed to allow other signalk plugins to receive notifications when certain values exceed a threshold.\n\n## configuration\nThe 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.\n\n### context\nTo create expressions you first have to define which signalk paths you will use and give them a short name:\nEach variable has two properties:\n\n#### path\nThe signalk path, should include the vessel URN i.e. `urn:mrn:imo:mmsi:244770688.navigation.speedOverGround.value`\nThe path can not be part of the notifications subtree since that tree is ignored by the plugin.\n\n#### name\nThe name to give to this path in the expressions defined below i.e. `sog`\n\n### Trigger\nfor each trigger the following values are required:\n\n#### condition\nThe condition that should trigger the event, uses [jexl](https://github.com/TomFrost/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`\n\n#### event\nThe name of the event that should be triggered when the condition is true.\n\n#### trigger type\nWhen to fire the event, has four available options\n\n- rising edge\n    + only sends the event when the condition becomes true\n- falling edge\n    + only sends the event when the condition becomes false\n- both edges \n    + sends the event when the condition changes\n- for all deltas\n    + send the event for all deltas while the conditon is true, including an event on the falling edge\n\n## use\nAfter setting this plugin up, other plugins can use the configured events to trigger actions by listening to them.\n\nThe following example sets up a simple listener that will write to the plugins debug log\n\n```js \nvar unsubscribes = [];\nmodule.exports = function(app) {\n  var plugin = {};\n\n  plugin.id = 'your-plugin';\n  plugin.name = 'your plugin';\n  plugin.description = 'A plugin to send notifications when an event occurs';\n\n  plugin.start = function(options, restartPlugin) {\n    let _notify = function(event) {\n        app.debug(`Event received: ${event.event}, type: ${event.type}`);\n    }\n    app.on('eventName', _notify);\n    unsubscribes.push(() => {\n      eventEmitter.removeListener(event, _notify);\n    });\n\n    app.setProviderStatus('Running');\n  };\n\n   plugin.stop = function() {\n    unsubscribes.forEach(f => f());\n    app.setProviderStatus('Stopped');\n  };\n  return plugin;\n}\n```\n\n## Development\n\nTo install this package for development clone it from git and run npm link.\n\n```\ngit clone https://github.com/codekilo/signalk-trigger.git\ncd signalk-trigger\nsudo npm link\n```\n\nThen go to the SignalK configuration directory (probably `~/.signalk`)  and link the module again:\n\n```\n$ cd .signalk \n$ npm link @codekilo/signalk-trigger-event\n```\n","readmeFilename":"README.md"}