Blynk input set time in nodered

Yes I’m getting this values as per parseInt but I used .toString(): on RTC function(moment.js);

but the problem is I have to keep inject the time stamp so the the updated real time values can be stored
and after that it is being comparable

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

so here above it is compare with the rtc and start time and if both clicks an output goes to the change node and further node (which are running good)…

but…
For continuous input of time inject(every 1 sec) causes the light on for some delay.

like it is not as soon as start when the both time reaches but after some seconds which was not an issue in single time inject.

You will need to have an inject node running constantly, set to say once every second, that’s the equivalent of a timer in a C++ sketch.

Without an overview of your flow it’s difficult to know how to help address the time delay issue.

Pete.

So can i send the picture as it will help to understand the visually.

Yes, post a screenshot taken with the Windows Sniping Tool or equivalent.

Pete.

If injecting it continuously the timer2 is starting after delay not as per inject single time.

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

this above code will send the payload to timer2 to start till stoptime-starttime

To help you with this, I need to be able to re-create your setup.
I cant do this because I don’t have an overview of your flow, and I don’t understand where the “RTC” time is coming from and what format that time data is ion.

Pete.

here the RTC real time is coming from Date/time formatter which is HH:mm and it is then converted in to seconds like HH * 3600+mm * 60 in realtimefunction node

So both the blynk and real time in same format and will be use for generating the output

please see the flow as it mentioned

I cant read any detail on the photograph that you’ve posted because it’s a picture of your monitor rather than a screenshot taken with windows Snipping tool.

Pete.

as i have mentioned earlier i can only send this type of format because i’m using on raspberry pi not on windows os. How can i send you the snip of it if you can suggest me any tool for raspberry pi

My Node-Red setup runs on a Raspberry Pi, but I access it via a browser on a windows machine.
The URL is <Your RPI IP address>:1880/

Pete.

It is not in public url, I can not access the 192.168.1.21:1800/ on my windows machine
as it is connected to same wifi network

Mine’s not a public URL either. on your Pi, if you type:

node-red-stop

followed by:

node-red-start

The results will look something like this:

pi@raspberrypi:~ $ node-red-stop
Stop Node-RED
Use   node-red-start   to start Node-RED again

pi@raspberrypi:~ $ node-red-start
Start Node-RED

Once Node-RED has started, point a browser at http://192.168.1.xxx:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output

followed by several hundred lines of data ....

You’ll see the URL and port that you’re supposed to be using to access the Node-Red interface from your PC.

Pete.

Actually I’m using node red on raspberry pi which is connected to a desktop through HDMI port.

and I can not access the link that is 192.168.1.21:1800/ on my windows laptop.

So how can i send the snip of my code through snipping tool?

Are you sure that you’re typing the correct port. It’s normally 1880 not 1800

I have no idea what screenshot tools are available for the Pi, I always use mine in headless mode, but I’m sure that if you do a bit of googling you’ll find a suitable tool.

Pete.

Ohh god!! I’m really really sorry for my typo, I got screen on my laptop here it is screen shot

Thanks pete

Okay, I spent quite a bit of time looking at your flow and couldn’t follow the logic, so I’ve changed it around and come-up with this, which also includes day numbers as well.

The output that feeds into the debug node is a 1 if the device controlled by the timer ios on, a 0 of its off.
As this would be sent once every second (the frequency that I’ve set for the timestamp inject node, I’ve added the RBE node that only allows the value to pass if it changes.

Functions:

Get values from Time Input Widget

var start_seconds = parseInt(msg.arrayOfValues[0],10);
var stop_seconds = parseInt(msg.arrayOfValues[1],10);
var active_days = msg.arrayOfValues[3]


flow.set('start_seconds',start_seconds);
flow.set('stop_seconds',stop_seconds);
flow.set('active_days',active_days);

// Update the text on the node to show the data from Blynk
node.status({text: "[ Start " + start_seconds + ", Stop " + stop_seconds + ", Days " + active_days + " ]"});

Seconds since midnight & Day Number

var time = msg.payload;
var th = time.split(':');
var result1 = th[0]*3600+th[1]*60; // result1 is current number of seconds since midnight


var date = new Date();
var str_daynum = date.getDay().toString(); // Get the day of the week (Mon = 1) as a string
flow.set('current_day',str_daynum);        // we are using a sring as we want to find it within the list of active days


// Update the text on the node to show the data from Blynk
node.status({text: "[ Time Now = " + result1 + ", Today = " + str_daynum  + " ]"});


msg.payload = result1; // output the current number of seconds since midnight
return msg;

Calculate On/Off Status

var current_seconds = msg.payload;
var start_seconds = flow.get('start_seconds');
var stop_seconds = flow.get('stop_seconds');

var current_day = flow.get("current_day");
var active_days = flow.get("active_days")

if (active_days.includes(current_day)) // Check that today is an active day
{
    if (current_seconds >= start_seconds && current_seconds < stop_seconds) // if we're within the on/off times then output a 1
    {
        msg.payload = 1 // ON
    }
    else
    {
        msg.payload = 0 // OFF   // else output a zero
    }
}
else
{
        msg.payload = 0 // OFF  // we get here if it wasn't an active day, so output a 0       
}

// Update the text on the node to show the on/off status
node.status({text: "[ " + msg.payload + " ]"});

return msg; // 1=on, 0=off This will be output once per second

These two nodes in the top right hand corner ensure that the values from the Time Input widget are synchronised when you do a deploy, or when the RPi reboots:

image

image

It’s going to be important that your RPI’s time is set correctly, as it needs to be in sync with the time on your mobile device (and I think the Blynk server, but I cant get my head around that now, it’s a bit too late in the day).
I have no idea what effect daylight saving time will have on all of this, but I guess we’ll find out this weekend :slightly_smiling_face:

Pete.

Thank you @PeteKnight It working very well from my nodes. Yes for daylight let me get back on that.