BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk input set time in nodered

When I’m using node red with blynk the problem is that in input time setting widget in the blynk the values of stop time and the days are not showing in the node valu[in node red]

Only the start time*3600 value is there so if my start time is 1 then the value is 3600.

How can i get the other values?

I’m guessing that you’re using a debug node set to it’s default of “msg”, which just shows msg.payload.
If you change the debug node to “complete msg object” you’ll see an array of values that includes start time, stop time, timezone, days of the week and GMT Offset…

image

Pete.

Thank you @PeteKnight. I have done the complete msg but the thing is never drop down the array function. It is working
Can you brief me how can i turn output between this start time and stop time?

If you click this arrow:

image

Then this arrow:

image

You’ll see the full debug information:

image

The stop time is referenced as msg.arrayOfValues[1]

Pete.

so do i need to write code in template or function or delay time for starting the output at start time and stopping the output at stop time?

How can i write this code can you give some hint, I’m new to this!
Thanks @PeteKnight

Yes, you would have to create some functions that took the data from the Time Input widget and did something with it.
This isn’t something I’ve ever done, as I always use Pete Scargill’s Big Timer node for all or my timing functions rather than using Blynk.

I guess it depends on what you want to achieve. If you’re not worried about days of the week and time zones then it would be simpler, but would still need some work.
The Blynk stop and start times are in seconds since midnight, so you’d need to find a way of getting the time since midnight and comparing it to the output from the Blynk time input widget.

Pete.

I want to On the output from blynk set time option as it will give start time and stop time. So how can i start and stop the output on arduino at given start time and stop time?

is there any timer needed? or any javascript needed?

I’ve merged your other post on the same subject into this one. It’s better to have everything in one place.

It would help people to assist you if you were clear about exactly what you wanted to achieve, with real world examples.

Pete.

I have done the timer clocking but as you mentioned that days of week, I can not figure out what to do with that ?

Output is working on and off

As my script is stop - start time so it will be always start the output with differentiate timing but what if
I want to start at the start time (not on the differentiate time) and stop at stop timing.

is there any other way to do this automatically to start and stop at blynk time input widget.

Posting photos of your monitor doesn’t really work. It’s much better to use something like the Windows Sniping tool and/or Copt and paste the code and add triple backticks at the beginning and end of the code.
Triple backticks look like this:
```

Also, I don’t really understand what this means:

As I said earlier, it would be much better if you described exactly what you’re trying to achieve in real world terms, rather than in hypothetical terms.

Pete.

I’m sorry for the photograph, Actually I’m running my program in raspberry pi and there is no snipping tool or other tool where i can show my flow. So I took photo.

as per current problem I’m facing is I want to turn on the light from blynk time input setting. and my light is connected to arduino (which is connected to Raspberry pi).

Both raspberry and arduino are working good on communication.

Now Real world example:
On the time input setting when i set the start time and stop time i wants to turn on the light in between and off when stop time reached.
this is my issue.


Now what i have done till now:
So
1> I get the start time value (which in array as you mentioned earlier)
2> I also get the stop time value (which in array as you mentioned earlier)
3> I substract it so i get the time to run the light
4> and light is on till that time and stop after that.

But…
I want to start on Real world time and stop on RTC. how can i do this i can not find any node there.

Hope it helps …

So you mentioned earlier that you wanted to use the day of the week information, are you planning on having different schedules on different days?

Pete.

yes I wanted to start it on selected days like , morning 7 to evening 7 on mon, tue, wed .
so for that period of time it will on and off.

I tried a lot to get value in function node (blynk’s time input widget) which is successfully stored in function node (i.e fun1).

Then the real value of time by getting from moment.js node and stored it to the function node.(i.e func2)

Now This two function values goes to another function where the real value of time(UTC) and the start time from the blynk will be compare and if that matches then the output light will be on till the stop time.

but here is the problem

  1. I use the context.flow which is used to get the values from the another function node
  2. I used to get the value as number (from fun2) and string from (fun1) so It cannot be compared
  3. i tried to convert it to string but this JavaScript is sending error like
    function is sending string object.

I can not figure out will it be useful or not . or is there any another method to compare the RTC and blynk input time widget values so that i can on my light.

This isn’t something that I’ve ever tried to do, but if yoy share what you’ve done so far I’ll take a look at it.

However, please don’t export a whole flow, as I have a rule that I don’t import flows into my Node-Red production environment unless I created them myself, and I don’t currently have a development environment that I could use for this.

If you post code then please use triple backticks at the beginning and end so that it displays correctly. Triple backticks look like this:
```

Pete.

------------------ This is from getting RTC from moment.js node and sending it to the function node-----------
//Function node 1
var time = msg.payload;
var th = time.split(':');
var result1 = th[0]*3600+th[1]*60;

msg.payload = result1;
flow.set('fred',msg.payload);
return msg;

//another function node getting values from the time input setting and sending to the function node
var start = msg.arrayOfValues[0];
var stop = msg.arrayOfValues[1];
var result1 = stop - start;

var result = {stsp:[start,stop,result1]};
//if(sttime == start){
//    var result = {payload:result1};
//    return result;    
//}
flow.set('gred',result);

return result;

This is the combined function node which will be compare the real time clock(HH:mm) and start time of blynk input widget and then send the output to the change node.

var fim = flow.get('fred');
var gim = flow.get('gred');
//var result = {payload : [gim,fim]};
fim = fim.toString();
var msg1 = {};
var msg2 = {};
var msg3 = {};
var msg4 = {};
var inter = '0';
msg1.payload = fim;
msg2.payload = gim;
msg3.payload = [fim,gim];
msg4.payload = msg3.payload[1].stsp[2];

if(msg3.payload[1].stsp[0] == msg3.payload[0] && inter == '0'){
    inter = '1';
    return msg4;
}
else if (msg3.payload[1].stsp[1] == msg3.payload[0] && inter == '1'){
    return msg4;
}

Note:
the final output will be goto change node and then timeout node is used to [stop-start](blynk input time setting) run the time untill it reaches its value.

but what problem i face is.

The RTC and starttime is not comparing unless and untill i inject the RTC(moment.js) time then comparison happens. and light on

but if I inject it periodically it will not stat immediately it reaches at starttime == RTC it will start the output after some seconds…

Can i do better than this. It is so complicated…

I don’t understand this part of your flow, or how these nodes are supposed to connect together.

Are you using the “Date/Time Formatter” node and injecting a timestamp into it, or are you using the Blynk RTC widget in some way?

Pete.

It is like this

timestampe(inject once) — > moment.js —> function1(context.flow) ------->
both are in function3
blynk write event------>function2(for getting time it is in seconds)------------->

sorry for this view as we discussed earlier i’m running in raspberry so I can only sent the pictures of it no snipping tools.

To answer the question about converting strings to integers, you van use the parseInt function. If you use this code then all of the values outputted from your second function will be numbers…

var start = parseInt(msg.arrayOfValues[0],10);
var stop = parseInt(msg.arrayOfValues[1],10);
var result1 = stop - start;

var result = {stsp:[start,stop,result1]};
//if(sttime == start){
//    var result = {payload:result1};
//    return result;    
//}
flow.set('gred',result);

return result;

Output from original code:

msg : Object
object
  stsp: array[3]
    0: "61380"
    1: "79680"
    2: 18300

Output from modified code:

msg : Object
object
  stsp: array[3]
    0: 61380
    1: 79680
    2: 18300

Pete.