Show Schedex Time on Dashboard

Hi all,

I am trying to show the on and off time of a timer on my Dashboard similar to the little tooltip you have below the Schedex node.

My current flow can be seen below:

13

Idea was: On the basis of my configuration (e.g on: sunset) I get a true or false from Schedex at the specified time which is changed to a bool to switch lights on and off. To show the respective time I inject a recurring info string that should emit the info object from where I can show the on and off time on the Dashboard. So far so good. However, as soon as I infect the info node also the "ToBool" function triggers and puts out "false". Is there any way how I can separate between external injection and push from the node? How have you realized this?

I use a status node to catch the status text from the schedex node and send it to a ui_text node in the dashboard. This eliminates the need for an inject node.

Hm that's interesting. I tried it but didn't get it to work :slight_smile: Would you mind showing an example flow? Is it really just the status node (configured to selected node and there you ticked Schedex) or is there more around it?

Many thanks in advance

I used the function below to extract/parse time from Schedex:

/* Output:
on_hrs, on_mins, off_hrs, off_mins
*/
// {"on":"Wed, 20 Mar 2019 15:10:13 GMT","off":"Tue, 19 Mar 2019 21:58:12 GMT","state":"on"}
if (msg.topic != 'info') return;

var re = "\\d+:\\d+";
var on = msg.payload.on.match(re);
var off = msg.payload.off.match(re);
var all = on[0] + ':' + off[0];  // simplify further processing
var nums = all.split(':');
// Get time zone offset
var d = new Date();
var n = (-d.getTimezoneOffset())/60;
// Restore UTC hours into local hours
nums[0] = (parseInt(nums[0]) + n) % 24;
nums[2] = (parseInt(nums[2]) + n) % 24;

return [{payload:nums[0]},{payload:parseInt(nums[1])},{payload:nums[2]},{payload:parseInt(nums[3])}];

The idea was to add UI controls to change the Schedex settings. I gave up the idea of UI control for Schedex because if the "random offset" is true then all the settings make no sense. I.e. the idea of UI control is applicable only if offset isn't set.

Thanks. It's strange sometimes - now got my initial flow working. The key thing was to add another switch node that checks the input type to be an object. Still would be nice without the recurring injection but can live with this for the time being :slight_smile:

Thanks for your input.

@aufruf You could try this flow:

[{"id":"a1743981.9668a","type":"status","z":"2190ec65.0a5c6c","name":"","scope":["167e4a09.e16596"],"x":460,"y":240,"wires":[["340245c2.df088a","ab8afb68.12d9a"]]},{"id":"167e4a09.e16596","type":"schedex","z":"2190ec65.0a5c6c","name":"","suspended":false,"lat":"","lon":"","ontime":"07:28","ontopic":"","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"goldenHour","offtopic":"","offpayload":"off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":480,"y":180,"wires":[["f580fb61.db8dc8"]]},{"id":"340245c2.df088a","type":"ui_text","z":"2190ec65.0a5c6c","group":"409c9c1e.fbbbe4","order":0,"width":0,"height":0,"name":"","label":"Status","format":"{{status.text}}","layout":"row-spread","x":610,"y":240,"wires":[]},{"id":"7fdd6dbb.39066c","type":"inject","z":"2190ec65.0a5c6c","name":"","topic":"","payload":"info","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":180,"wires":[["167e4a09.e16596"]]},{"id":"fc9c6bcc.2d71e8","type":"inject","z":"2190ec65.0a5c6c","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":220,"wires":[["167e4a09.e16596"]]},{"id":"ab8afb68.12d9a","type":"debug","z":"2190ec65.0a5c6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":280,"wires":[]},{"id":"9245161.12389e8","type":"inject","z":"2190ec65.0a5c6c","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":260,"wires":[["167e4a09.e16596"]]},{"id":"b2fc1a5c.db82e8","type":"inject","z":"2190ec65.0a5c6c","name":"","topic":"","payload":"toggle","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":300,"wires":[["167e4a09.e16596"]]},{"id":"f580fb61.db8dc8","type":"debug","z":"2190ec65.0a5c6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":670,"y":180,"wires":[]},{"id":"32c2d5e4.803ee2","type":"inject","z":"2190ec65.0a5c6c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":140,"wires":[["8590a270.9af608"]]},{"id":"8590a270.9af608","type":"change","z":"2190ec65.0a5c6c","name":"set ontime","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"ontime\":\"sunrise\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":140,"wires":[["167e4a09.e16596"]]},{"id":"409c9c1e.fbbbe4","type":"ui_group","z":"","name":"Timer","tab":"32fae57a.692b52","disp":true,"width":"6","collapse":false},{"id":"32fae57a.692b52","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Have you taken account of the fact that the status node does not send a payload, so the dashboard node has to use msg.status.text? It seems that schedex sends an incorrect status when first deployed, but if you change its state (on/off/toggle) or change its program, it starts to behave properly. I did not run into this with earlier versions (my production systems are at least a year old and run v1.1.0), so I will raise an issue on GitHub.

1 Like