How to set 2 timestamp for the same request?

@DamianosS @Colin
Hello. i just set @Colin solution. I will test until tommorow. but are you sure about 590,05 second becaouse it's near 59 second. 9 minutes 59 second 05
maybe you want to say 9 minutes 59 second and 50 so i think it would be 590,5 second
Or near 60 : 9minutes 59 second 95 599,5

I meant this solution. Have you been reading the posts?

you're right . i missed this post . i will change it immediately

PS - you can leave the topic blank if you like, as all "blanks" are the same :slight_smile:

What if you dont use a Delay node ... have Cron plus request the data from Http-request node every 10 minutes ... the request will take a bit and the time may be a couple of seconds off ..
but simply do not show the seconds on the x-axis of the ui_chart :wink:

image

@mykerinos1 requires the more rapid polling for the real time monitoring, but wants to send it to a database at a slower rate.

@Colin @DamianosS @UnborN
Hello. i'm still losing second with your setting @Colin .since yesterday 14:40 i lost 3 second
@UnborN
Second doesn't appear in the chart it's to not have something like 13:12 :13:23 13:34 in my chart but 13:10 ,13:20,13:30

Can you show us what the debug coming out of the delay node looks like and how you have configured that node. Also a few of the messages going into the delay node.

Cron-plus plus can have two schedules and separate outputs for each one ..as suggested in your previous thread

1st output - schedule 1 - every one second ? does the http-request and does whatever it does with the result and also saves the latest temperature to Flow Context.

2nd output schedule2 - every 10 minutes - triggers a Function node that prepares the query for the DB (Btw what database you are using ? ) by getting the latest temperature from Flow Context (saved from schedule 1).

In order to round ( zero out any possible seconds when writing to the db you can use the moment library to round them down)

Test Flow:

[{"id":"583baf7cb73539c9","type":"function","z":"54efb553244c241f","name":"query for DB","func":"let time = moment().format(\"YYYY-MM-DD HH:mm:00\")\nlet temperature = flow.get(\"temperature\")\n\nmsg.topic = `INSERT INTO Temperatures (dt, TEMP01) VALUES (${time}, ${temperature})`;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"moment","module":"moment"}],"x":570,"y":1600,"wires":[["883d676b910e5934"]]},{"id":"7c73ecd0459ce0ac","type":"cronplus","z":"54efb553244c241f","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"schedule1","topic":"everySecond","payloadType":"default","payload":"","expressionType":"cron","expression":"* * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule2","topic":"every10Min","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":320,"y":1580,"wires":[["4e7624aef5a8bb3a"],["583baf7cb73539c9"],[],[]]},{"id":"4e7624aef5a8bb3a","type":"http request","z":"54efb553244c241f","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":570,"y":1520,"wires":[["023fda9caa60b3c6"]]},{"id":"023fda9caa60b3c6","type":"change","z":"54efb553244c241f","name":"","rules":[{"t":"set","p":"temperature","pt":"flow","to":"payload.whatever","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":1520,"wires":[[]]},{"id":"883d676b910e5934","type":"function","z":"54efb553244c241f","name":"DB","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":1600,"wires":[[]],"icon":"node-red/leveldb.png"}]

ps. @ghayne 's question went unanswered. are you doing a http-request every second? that is too fast and you may get blocked by the weatherapi

@Colin
Hello Here's what i have before Delay node
coming in Delay

Something interesting. Before delay node data appears each 3 seconds

Then my setting in delai node
delaynode setting

in the outpout of delay node it's the same like before delay node

@UnborN
i need the http request to feed database. Http request must feed database and live in the same time i can't do 2 request because i ve got conflict.
to answer to @ghayne i never had trouble to request each second.

sorry i dont understand .. we are not doing two requests in the flow i shared .. only one request every second from the top wire of Cron node, which saves the value to flow Context that the second line can then access without having to do an additional request

@UnborN
okkkkk it's me don''t understand how it work. so change my timestamp with your cron node +
Live still works
But i 've an error telling me URL not specidied but it's in http request and feeding database doesn't work

ofcourse many things are not going to work just by importing the example flow ..
more modifications are needed .. especially now that you shared a screenshot of the msg from the http-request and we understand that its not only temperature that you are saving but also humidity and many other values.

Without seeing your Flow its impossible to suggest anything more .. can you Export it and share it to see how you wired everything and get a better understanding of the bigger picture :wink:

ps. if you are unfamiliar with Context .. you can read about it here

For sure it must be better :smile:

[{"id":"59cac29d4359eaaf","type":"function","z":"2d7932fb075f9e64","name":"function 1","func":"const FtoC = farenheit =>(farenheit-32)*5/9;\nconst VToKmh = Vmiles =>(Vmiles*1.609);\nconst RToKmh = Rmiles =>(Rmiles*1.609);\nconst IntTomm = InTmm =>(InTmm*0.2);\nconst PJtomm = PJ =>(PJ*0.2);\nconst PMtomm = PM =>(PM*0.2);\nconst Pan = PAn =>(PAn*0.2);\nconst Plive = PLive =>(PLive*0.2)\nconst PressToHpa = PressHpa =>(PressHpa*33.8639)\nmsg.payload.ts = msg.payload.data.ts\nmsg.payload.tmp = FtoC(msg.payload.data.conditions[0].temp)\nmsg.payload.hum = (msg.payload.data.conditions[0].hum)\nmsg.payload.vents = VToKmh(msg.payload.data.conditions[0].wind_speed_avg_last_10_min)\nmsg.payload.rafale = RToKmh(msg.payload.data.conditions[0].wind_speed_hi_last_10_min)\nmsg.payload.pluiejour =PJtomm(msg.payload.data.conditions[0].rainfall_daily)\nmsg.payload.intensite = IntTomm(msg.payload.data.conditions[0].rain_rate_last)\nmsg.payload.pluiemois = PMtomm(msg.payload.data.conditions[0].rainfall_monthly)\nmsg.payload.pluiean = Pan(msg.payload.data.conditions[0].rainfall_year)\nmsg.payload.pluielive = Plive(msg.payload.data.conditions[0].rainfall_last_15_min)\nmsg.payload.pression = PressToHpa(msg.payload.data.conditions[2].bar_sea_level)\nmsg.topic= `INSERT INTO DAVIS (Date,TmpExt,HumExt,Vents,Rafale,PluInt,PluJour,PluMois,PluAn,PluLive,Pression) VALUES (:ts,:tmp,:hum,:vents,:rafale,:intensite,:pluiejour,:pluiemois,:pluiean,:pluielive,:pression)`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":460,"wires":[["bd10f862acace18c"]]},{"id":"62bd209e930379c3","type":"moment","z":"2d7932fb075f9e64","name":"","topic":"","input":"","inputType":"date","inTz":"Europe/Paris","adjAmount":0,"adjType":"days","adjDir":"add","format":"yyyy/MM/DD HH:mm:ss","locale":"fr","output":"payload.data.ts","outputType":"msg","outTz":"Europe/Paris","x":480,"y":520,"wires":[["59cac29d4359eaaf"]]},{"id":"bd10f862acace18c","type":"mysql","z":"2d7932fb075f9e64","mydb":"8a85ce1f74813a1a","name":"meteo","x":890,"y":460,"wires":[["8b8f0508287c97bf"]]},{"id":"7db14e3e4e121f77","type":"websocket out","z":"2d7932fb075f9e64","name":" LIVE 1 seconde","server":"765b59f8a5bea7b3","client":"","x":1100,"y":360,"wires":[]},{"id":"6a49cbec9d34ee28","type":"http request","z":"2d7932fb075f9e64","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.86.85/v1/current_conditions","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":510,"y":360,"wires":[["7db14e3e4e121f77"]]},{"id":"8b8f0508287c97bf","type":"debug","z":"2d7932fb075f9e64","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":460,"wires":[]},{"id":"d9bfa443716da41b","type":"cronplus","z":"2d7932fb075f9e64","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"schedule1","topic":"everySecond","payloadType":"default","payload":"","expressionType":"cron","expression":"* * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule2","topic":"every10Min","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":120,"y":380,"wires":[["6a49cbec9d34ee28"],["62bd209e930379c3"],[],[]]},{"id":"8a85ce1f74813a1a","type":"MySQLdatabase","name":"","host":"192.168.86.78","port":"3306","db":"mymeteo_varenne","tz":"","charset":"UTF8"},{"id":"765b59f8a5bea7b3","type":"websocket-listener","path":"live","wholemsg":"false"}]

I see from your Flow that you didnt use an important step which was saving the data in Context
so you can later read in the Function node that does the sql Insert query

Maybe this will work ?

[{"id":"59cac29d4359eaaf","type":"function","z":"54efb553244c241f","name":"function 1","func":"let time = moment().format(\"YYYY/MM/DD HH:mm:00\")  // using the moment library to zero any possible seconds\nlet weather = flow.get(\"weather\")  // read from Context - that is updated every second\n\n\nconst FtoC = farenheit => (farenheit - 32) * 5 / 9;\nconst VToKmh = Vmiles => (Vmiles * 1.609);\nconst RToKmh = Rmiles => (Rmiles * 1.609);\nconst IntTomm = InTmm => (InTmm * 0.2);\nconst PJtomm = PJ => (PJ * 0.2);\nconst PMtomm = PM => (PM * 0.2);\nconst Pan = PAn => (PAn * 0.2);\nconst Plive = PLive => (PLive * 0.2)\nconst PressToHpa = PressHpa => (PressHpa * 33.8639)\n\n// msg.payload.ts = weather.data.ts\nmsg.payload.ts = time\nmsg.payload.tmp = FtoC(weather.data.conditions[0].temp)\nmsg.payload.hum = (weather.data.conditions[0].hum)\nmsg.payload.vents = VToKmh(weather.data.conditions[0].wind_speed_avg_last_10_min)\nmsg.payload.rafale = RToKmh(weather.data.conditions[0].wind_speed_hi_last_10_min)\nmsg.payload.pluiejour = PJtomm(weather.data.conditions[0].rainfall_daily)\nmsg.payload.intensite = IntTomm(weather.data.conditions[0].rain_rate_last)\nmsg.payload.pluiemois = PMtomm(weather.data.conditions[0].rainfall_monthly)\nmsg.payload.pluiean = Pan(weather.data.conditions[0].rainfall_year)\nmsg.payload.pluielive = Plive(weather.data.conditions[0].rainfall_last_15_min)\nmsg.payload.pression = PressToHpa(weather.data.conditions[2].bar_sea_level)\n\nmsg.topic = `INSERT INTO DAVIS (Date,TmpExt,HumExt,Vents,Rafale,PluInt,PluJour,PluMois,PluAn,PluLive,Pression) VALUES (:ts,:tmp,:hum,:vents,:rafale,:intensite,:pluiejour,:pluiemois,:pluiean,:pluielive,:pression)`;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"moment","module":"moment"}],"x":540,"y":1860,"wires":[["bd10f862acace18c","d02c91b60dcec090"]]},{"id":"bd10f862acace18c","type":"mysql","z":"54efb553244c241f","mydb":"8a85ce1f74813a1a","name":"meteo","x":730,"y":1860,"wires":[["8b8f0508287c97bf"]]},{"id":"7db14e3e4e121f77","type":"websocket out","z":"54efb553244c241f","name":" LIVE 1 seconde","server":"765b59f8a5bea7b3","client":"","x":760,"y":1740,"wires":[]},{"id":"6a49cbec9d34ee28","type":"http request","z":"54efb553244c241f","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.86.85/v1/current_conditions","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":550,"y":1700,"wires":[["7db14e3e4e121f77","8abc89558d8bbe7b"]]},{"id":"8b8f0508287c97bf","type":"debug","z":"54efb553244c241f","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":1860,"wires":[]},{"id":"d9bfa443716da41b","type":"cronplus","z":"54efb553244c241f","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":4,"options":[{"name":"schedule1","topic":"everySecond","payloadType":"default","payload":"","expressionType":"cron","expression":"* * * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"schedule2","topic":"every10Min","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":300,"y":1780,"wires":[["6a49cbec9d34ee28"],["59cac29d4359eaaf"],[],[]]},{"id":"8abc89558d8bbe7b","type":"change","z":"54efb553244c241f","name":"","rules":[{"t":"set","p":"weather","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":1660,"wires":[[]]},{"id":"d02c91b60dcec090","type":"debug","z":"54efb553244c241f","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":680,"y":1940,"wires":[]},{"id":"8a85ce1f74813a1a","type":"MySQLdatabase","name":"","host":"192.168.86.78","port":"3306","db":"mymeteo_varenne","tz":"","charset":"UTF8"},{"id":"765b59f8a5bea7b3","type":"websocket-listener","path":"live","wholemsg":"false"}]

It seems it works :slight_smile:
i don't really understand because debug 2 is empty but in DB i have data. I ll wait a couple of time to tell you the result but i think it will be ok
Thanks a lot

1 Like

thats because most probably the mysql node doesnt produce a msg when you do an Insert.
Just delete it .. there is no need for debug 2 there.

Ok until now it work perfectly :smiley:

I wanted to see the timestamps. This method will work if you get it right.

@Colin i wish you won't be sad but i keep @UnborN Method. I know you spend a lot of time trying to help me and i thanks you a lot for that
@UnborN
i didn't lost any second since yesterday. thank you for your help. this is exactly what i'm waiting for. Thanks a lot.
Thanks also to all people trying to help me