# timer picker dashboard for Schedex

**URL:** <https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222>\
**Category:** Dashboard\
**Created:** [26 November 2018 23:42 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222 "2018-11-26T23:42:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kachlf](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kachlf](https://discourse.nodered.org/u/kachlf)\
**Post date:** [26 November 2018 23:42 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/1 "2018-11-26T23:42:01Z")

</div>

I have a function that takes input from dashboard text input as a time selection and it calculates hours and minutes, and it sets other variables and returns the msg object to the Schedex node but it's not setting the time or the other variables when the flow is executed. I have red the documentation multiple times and followed it to my best understanding and it's still not configuring my Schedex node. Schedex documentation mentions two ways to send configuration to Schedex node, the first way is to set msg.palyload.variable or send all the configuration as one string in mgs.payload I will post the two versions of the function code below. if you would like to read the documentation for Schedex can be found below [https://www.npmjs.com/package/node-red-contrib-schedex](https://www.npmjs.com/package/node-red-contrib-schedex)

```
    msgTemp = msg.payload;
    time = msgTemp / 1000;
    // calculates hour from seconds input
    h = Math.floor(time / 3600); 
    // calculates minutes from remainder 
    m = Math.floor(time % 3600 / 60); 
    // ontime formatted for Schedex standards
    ontime = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2);
    //setting ontime
    msg.payload.ontime = ontime;
    //setting onpayload
    msg.payload.onpayload = "1";
    //enabling schedule for every time of the week
    msg.payload.mon = true;
    msg.payload.tue	= true;
    msg.payload.wed	= true;
    msg.payload.thu	= true;
    msg.payload.fri	= true;
    msg.payload.sat = true;
    msg.payload.sun = true;
    //the documentations mentions that to set the variables from the ui 
    //it has to be in programmatic control, I have put this in the 
    //payload and it's not working.
    //i think my issue is with the line below but i can't figure it out
    msg.payload = "'## Programmatic Control";
    return msg;

```

here is the other version where all the configurations are stored on msg.payload as one string

```
    msgTemp = msg.payload;
    time = msgTemp / 1000;
    // calculates hour from seconds input
    h = Math.floor(time / 3600); 
    // calculates minutes from remainder 
    m = Math.floor(time % 3600 / 60); 
    ontime = "onetime " + ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2) 
    + " ";
    onpayload = "onpayload 1 ";
    mon = "mon true ";
    tue = "tue true ";
    wed = "wed true ";
    thu = "thu true ";
    fri = "fri true ";
    sat = "sat true ";
    sun = "sun true ";
    msg.payload = ontime + onpayload + mon + tue + wed + thu + fri + sat 
    + sun;
    return msg;

```

your help is greatly appreciated

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 November 2018 07:11 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/2 "2018-11-27T07:11:03Z")

</div>

For object type of configuration:

> [@kachlf](#):
>
> msg.payload = "'## Programmatic Control";

This line is not needed at all.

After you get the data from your incoming `msg.payload` , it should be cleaned up and then add all needed properties to it.

```auto
ontime = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2);
//clean up the msg.payload object
msg.payload = {};
//setting ontime
msg.payload.ontime = ontime;
//add other properties 

```

---

<div class="post-metadata">

**Author:** ![kachlf](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kachlf](https://discourse.nodered.org/u/kachlf)\
**Post date:** [27 November 2018 13:56 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/3 "2018-11-27T13:56:11Z")

</div>

Thanks for your response hotNipi I did what you have suggested and i'm getting unsupported input error in the schedex node. I think the reason is because msg.payload still has a number that is passed as an input from the time picker in the dashboard which is the on time in seconds. I tried making it an empty string but it still gave me the same error.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 November 2018 15:45 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/4 "2018-11-27T15:45:11Z")

</div>

If you declare `msg.payload = {};` there is no number anymore.

You should debug the `ontime` value after calculations. I think it does not do the right thing.  
PS. Calculations are correct. The formatting needs attention.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 November 2018 15:49 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/5 "2018-11-27T15:49:24Z")

</div>

you can display a variable in the the middle of a function by using `node.warn("ontime=" + ontime);`  
This will display in the debug tab of the sidebar

---

<div class="post-metadata">

**Author:** ![kachlf](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kachlf](https://discourse.nodered.org/u/kachlf)\
**Post date:** [27 November 2018 18:45 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/6 "2018-11-27T18:45:31Z")

</div>

so schedex asks for time in 24 hour format like so 0:00, is that correct? and my ontime holds the time after calculation in the same format 00:00 I tested it to verify.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 November 2018 19:16 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/7 "2018-11-27T19:16:48Z")

</div>

Might be better to deal with actual data. Can you place debug node after your function node and set it to show complete msg and then share the output. With real data input if possible. Also it helps if you share the complete function node content.

---

<div class="post-metadata">

**Author:** ![kachlf](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kachlf](https://discourse.nodered.org/u/kachlf)\
**Post date:** [27 November 2018 19:46 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/8 "2018-11-27T19:46:57Z")

</div>

Hey hotNipi, I miss read your first post, it worked like you said. after i got what i needed from the msg.payload, I cleared the object per your suggestion and then set all my variables and i didn't get an unsupported input error like before, I will set some timers and see if it works like it's suppose to. Thanks for your help again

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 November 2018 19:51 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/9 "2018-11-27T19:51:19Z")

</div>

Yeah. I was already deeply digging in the schedex node sources 😃

---

<div class="post-metadata">

**Author:** ![TailFire](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@TailFire](https://discourse.nodered.org/u/TailFire)\
**Post date:** [8 November 2019 03:41 UTC](https://discourse.nodered.org/t/timer-picker-dashboard-for-schedex/5222/10 "2019-11-08T03:41:34Z")

</div>

Could one of you post a working flow. I have been trolling this thread to achieve the same thing..

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/02176c1975f5d268c91556b5168198005f856444.png)  
I am sorry I will have to go back and re-read the how to upload flows if you need me to post my flow.  
@kachlf I am experiencing the same unsupported input error from schedex.
