|
| 1 | +<script type="text/javascript"> |
| 2 | + RED.nodes.registerType('signalk-send-notification',{ |
| 3 | + category: 'output', |
| 4 | + color: '#a6bbcf', |
| 5 | + defaults: { |
| 6 | + name: {value:""}, |
| 7 | + path: {value: ""}, |
| 8 | + state: {value:"alarm"}, |
| 9 | + message: {value: ""}, |
| 10 | + visual: {value: true}, |
| 11 | + sound: {value: true} |
| 12 | + }, |
| 13 | + inputs:1, |
| 14 | + outputs:0, |
| 15 | + align: 'right', |
| 16 | + icon: "bridge.png", |
| 17 | + label: function() { |
| 18 | + return this.name||"signalk-send-notification"; |
| 19 | + } |
| 20 | + }); |
| 21 | +</script> |
| 22 | + |
| 23 | +<script type="text/x-red" data-template-name="signalk-send-notification"> |
| 24 | + <div class="form-row"> |
| 25 | + <label for="node-input-name"><i class="icon-tag"></i> Name</label> |
| 26 | + <input type="text" id="node-input-name" placeholder="Name"> |
| 27 | + </div> |
| 28 | + <div class="form-row"> |
| 29 | + <label for="node-input-path"><i class="icon-tag"></i> Path</label> |
| 30 | + <input type="text" id="node-input-path" placeholder="Path"> |
| 31 | + </div> |
| 32 | + <div class="form-row"> |
| 33 | + <label for="node-input-state"><i class="icon-tag"></i> State</label> |
| 34 | + <select id="node-input-state" placeholder="State"> |
| 35 | + <option value="normal">Normal</option> |
| 36 | + <option value="alert">Alert</option> |
| 37 | + <option value="warn">Warn</option> |
| 38 | + <option value="alarm">Alarm</option> |
| 39 | + <option value="emergency">Emergency</option> |
| 40 | + </select> |
| 41 | + </div> |
| 42 | + <div class="form-row"> |
| 43 | + <label for="node-input-visual"><i class="icon-tag"></i> Visual</label> |
| 44 | + <input type="checkbox" id="node-input-visual" placeholder="Visual"> |
| 45 | + </div> |
| 46 | + <div class="form-row"> |
| 47 | + <label for="node-input-sound"><i class="icon-tag"></i> Sound</label> |
| 48 | + <input type="checkbox" id="node-input-sound" placeholder="Sound"> |
| 49 | + </div> |
| 50 | + <div class="form-row"> |
| 51 | + <label for="node-input-message"><i class="icon-tag"></i> Message</label> |
| 52 | + <input type="text" id="node-input-message" placeholder="Message"> |
| 53 | + </div> |
| 54 | +</script> |
| 55 | + |
| 56 | +<script type="text/x-red" data-help-name="signalk-send-notification"> |
| 57 | + |
| 58 | + <p>Output that sends a SignalK notification</p> |
| 59 | + |
| 60 | + <p>If the input payload is an object, then it will use the keys path, state, method, and message. Example below. Otherwise it will use the configured values.</p |
| 61 | + |
| 62 | +<p>To specify all the info, send:</p> |
| 63 | + <pre><code class="javascript"> |
| 64 | +{payload: { |
| 65 | + "path":"notifications.testNotification", |
| 66 | + "state":"alarm", |
| 67 | + "method":["visual","sound"], |
| 68 | + "message":"this is a notification message" |
| 69 | +}} |
| 70 | +</code></pre> |
| 71 | + |
| 72 | +<p>Or to specify some of the info, send:</p> |
| 73 | + <pre><code class="javascript"> |
| 74 | +{payload: { |
| 75 | + "state":"normal", |
| 76 | +}} |
| 77 | +</code></pre> |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +</script> |
0 commit comments