mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add support for pushover sound selection.
This commit is contained in:
parent
5568238058
commit
1557f53e1c
@ -47,8 +47,8 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="pushover">
|
<script type="text/x-red" data-help-name="pushover">
|
||||||
<p>Uses Pushover to push the <b>msg.payload</b> to a device that has the Pushover app installed.</p>
|
<p>Uses Pushover to push the <b>msg.payload</b> to a device that has the Pushover app installed.</p>
|
||||||
<p>Optionally uses <b>msg.topic</b> to set the title, <b>msg.device</b> to set the device, and <b>msg.priority</b>
|
<p>Optionally uses <b>msg.topic</b> to set the title, <b>msg.device</b> to set the device, <b>msg.priority</b>
|
||||||
to set the priority, if not already set in the properties.</p>
|
to set the priority, and <b>msg.sound</b> to set a named sound, if not already set in the properties.</p>
|
||||||
<p>The User-key and API-token are stored in a separate credentials file.</p>
|
<p>The User-key and API-token are stored in a separate credentials file.</p>
|
||||||
<p>Uses Pushover. See <i><a href="https://pushover.net" target="_new">this link</a></i> for more details.</p>
|
<p>Uses Pushover. See <i><a href="https://pushover.net" target="_new">this link</a></i> for more details.</p>
|
||||||
</script>
|
</script>
|
||||||
|
@ -45,6 +45,7 @@ module.exports = function(RED) {
|
|||||||
var titl = this.title || msg.topic || "Node-RED";
|
var titl = this.title || msg.topic || "Node-RED";
|
||||||
var pri = this.priority || msg.priority || 0;
|
var pri = this.priority || msg.priority || 0;
|
||||||
var dev = this.device || msg.device;
|
var dev = this.device || msg.device;
|
||||||
|
var sound = msg.sound || null;
|
||||||
if (isNaN(pri)) {pri=0;}
|
if (isNaN(pri)) {pri=0;}
|
||||||
if (pri > 2) {pri = 2;}
|
if (pri > 2) {pri = 2;}
|
||||||
if (pri < -2) {pri = -2;}
|
if (pri < -2) {pri = -2;}
|
||||||
@ -61,6 +62,7 @@ module.exports = function(RED) {
|
|||||||
expire: 600
|
expire: 600
|
||||||
};
|
};
|
||||||
if (dev) { pushmsg.device = dev; }
|
if (dev) { pushmsg.device = dev; }
|
||||||
|
if (typeof(sound) === 'string') { pushmsg.sound = sound; }
|
||||||
//node.log("Sending "+JSON.stringify(pushmsg));
|
//node.log("Sending "+JSON.stringify(pushmsg));
|
||||||
pusher.send( pushmsg, function(err, response) {
|
pusher.send( pushmsg, function(err, response) {
|
||||||
if (err) { node.error("Pushover Error: "+err); }
|
if (err) { node.error("Pushover Error: "+err); }
|
||||||
|
Loading…
Reference in New Issue
Block a user