node-red-contrib-eztimer
Advanced tools
Comparing version
55
index.js
@@ -115,9 +115,16 @@ const util = require('util'); | ||
handled = true; | ||
node.send({ | ||
topic: 'info', | ||
payload: { | ||
name: function() { | ||
return node.name || 'eztimer'; | ||
}(), | ||
on: function() { | ||
var ret = { | ||
name: node.name || 'eztimer', | ||
state: function() { | ||
if (config.timerType == '2') return undefined; // Trigger | ||
if (isSuspended()) return 'suspended'; | ||
if (state) { return 'on' } else { return 'off' } | ||
}() | ||
} | ||
if (config.timerType == '1') { | ||
// on/off timer | ||
ret.on = { | ||
property: 'msg.' + events.on.property, | ||
value: events.on.value | "<none>", | ||
nextEvent: function() { | ||
if (isSuspended()) return 'suspended'; | ||
@@ -127,4 +134,8 @@ if (events.on.type == '9') return 'manual'; | ||
return events.on.moment.toDate().toString() | ||
}(), | ||
off: function() { | ||
}() | ||
} | ||
ret.off = { | ||
property: 'msg.' + events.on.property, | ||
value: events.on.value | "<none>", | ||
nextEvent: function() { | ||
if (config.timerType == '2') return undefined; // Trigger | ||
@@ -134,13 +145,21 @@ if (isSuspended()) return 'suspended'; | ||
return events.off.moment.toDate().toString() | ||
}(), | ||
state: function() { | ||
if (config.timerType == '2') return undefined; // Trigger | ||
}() | ||
} | ||
} else { | ||
// trigger | ||
ret.trigger = { | ||
property: 'msg.' + events.on.property, | ||
value: events.on.value | "<none>", | ||
nextEvent: function() { | ||
if (isSuspended()) return 'suspended'; | ||
if (state) { return 'on' } else { return 'off' } | ||
}(), | ||
ontopic: events.on.topic, | ||
onpayload: events.on.payload, | ||
offtopic: events.off.topic, | ||
offpayload: events.off.payload | ||
if (events.on.type == '9') return 'manual'; | ||
if (!events.on.moment) return 'error'; | ||
return events.on.moment.toDate().toString() | ||
}() | ||
} | ||
} | ||
node.send({ | ||
topic: 'info', | ||
tag: config.tag || 'eztimer', | ||
payload: ret | ||
}); | ||
@@ -147,0 +166,0 @@ } else { |
{ | ||
"name": "node-red-contrib-eztimer", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A simple-yet-flexible timer/scheduler for node-red", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -79,3 +79,3 @@ # eztimer | ||
| `off` | Triggers manual off mode and causes eztimer to emit the configured `off` event. Manual mode is reset when the next `on` or `off` time is reached | | ||
| `info` | Eztimer emits an object containing the `on` and `off` times in UTC format. It also contains the state which is either `on` or `off`. | | ||
| `info` | Eztimer emits an object containing the `on` and `off` (or `trigger`) times in UTC format. It also contains the state which is either `on` or `off` (for on/off type). | | ||
| `cancel` | Cancels the current run (if any) of the timer (_without_ emitting an `off` event). | | ||
@@ -119,2 +119,4 @@ | ||
# Change Log | ||
## 1.1.3 | ||
* Modified `info` output be more informative and logical. Fixed issue where `info` wouldn't work for `trigger` timer type. [credit @marc-gist](https://github.com/mrgadget/node-red-contrib-eztimer/issues/14). | ||
@@ -121,0 +123,0 @@ ## 1.1.2 |
81098
1.45%870
2.23%177
1.14%