I was publishing sunrise &sunset time but while using in code its not working. can anyone assist me?

I am using MQTT for a small project where through openweather API and Node-red i am publishing surise time of a location which is taken as input through a form in node-red dashboard. based on this time i was trying to turn led if its night and off if its day. but i am unable extract two values from the topic. i was publishing sunrise and sunset time but while using in code its not working. can anyone assist me in this?
Solution:
msg.payload : Object
{ sunrise: 1713645121, sunset: 1713684720 }
msg.payload : Object
{ sunrise: 1713645121, sunset: 1713684720 }
this is the sample payload i am publishing...
Jump to solution
4 Replies
Umesh Lokhande
Umesh Lokhande8mo ago
Hi @Shrushti I hope you're using JSON node palette to process MQTT payload. In this case usemsg.payload string and then split the payload. Please refer https://discourse.nodered.org/t/how-to-split-mqtt-tag-values/10794/3. As @techielew mentioned, we're preparing for TODAY's Engineering Hour. I'll write you detail response late evening.
electro_coco
electro_coco8mo ago
Jsonfy the data so it can be extracted properly @Shrushti
LMtx
LMtx8mo ago
Please share the sample MQTT Payload that you are using and the logic to extract the values.
Solution
Shrushti
Shrushti8mo ago
msg.payload : Object
{ sunrise: 1713645121, sunset: 1713684720 }
msg.payload : Object
{ sunrise: 1713645121, sunset: 1713684720 }
this is the sample payload i am publishing it works now 👍 thanks @LMtx @Umesh Lokhande @electro_coco and @techielew
Want results from more Discord servers?
Add your server