A TO and FROM payload issue

I thought I was going mad, but I have stumbled upon a problem from the
node-red-contrib-sun-position, when using the Moon Node.

The payload output includes the following:-

illumination: object
fraction: 0.9986036727069301
phase: object
   from: 0.466136806691289
   to: 0.533863193308711
   id: "fullMoon"
   emoji: "🌝"
   code: ":full_moon_with_face:"
   name: "Full Moon"
   weight: 1
   css: "wi-moon-full"
   phaseValue: 0.48810279726926675
   angle: -3.085705283802389

So the snag is this.
I want to capture the from and to data and add this to a function, but I can't, because
msg.payload.illumination.phase**.from** is an issue and so is
msg.payload.illumination.phase**.to** an issue, how do I get round this problem?

I'm not quite clear on what the issue is.

Is phase a property beneath the illumination property, or alongside it? It isn't entirely clear from what you have pasted as the indenting may be misleading.

Can you share a screenshot of the object from the Debug sidebar so we can see its true structure? Alternatively, click the 'copy value' button in the debug sidebar alongside the message so we can see the full structure?

That is because the data is not in payload from the looks of what you have posted, it looks like it is in msg.illumination.phase.from

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

Thanks for your replies, my fault I didn't explain the issue properly.
I have been using Node-Red for a couple of years now, so I know how to obtain the path and data of any messages and have built some fairly complex projects.

What was puzzling me was that if I simply write the following in a function node I got an error, without running it.

var x = msg.payload.illumination.phase.from
var y = msg.payload.illumination.phase.to

So it really doesn't matter what the payload is as I never had the opportunity to run it.

I asked the question as I couldn't see any particular reason why this should be a problem. Since then I have rebooted Node-Red and the issue has gone away and I can now write this into the function. It seems Node-Red itself had some issue and perhaps I should have rebooted it in the first place before asking the question.

Just for reference the Moon Node has the following output of the complete msg object, showing the only msg outside of the payload is the lat, lon and topic.

{"_msgid":"a066365ad9562745","lat":51.509865,"lon":-0.118092,"payload":{"ts":1716539734000,"lastUpdate":"2024-05-24T08:35:34.000Z","lastUpdateStr":"2024-05-24T09:35:34","latitude":51.509865,"longitude":-0.118092,"angleType":"deg","azimuth":275.8934816671064,"altitude":-39.24643914147571,"altitudeDegrees":-39.24643914147571,"azimuthDegrees":275.8934816671064,"altitudeRadians":-0.6849795827023278,"azimuthRadians":4.815249639881621,"distance":387839.64345437713,"parallacticAngle":43.92348800383688,"illumination":{"fraction":0.9927357733030052,"phase":{"from":0.466136806691289,"to":0.533863193308711,"id":"fullMoon","emoji":"🌝","code":":full_moon_with_face:","name":"Full Moon","weight":1,"css":"wi-moon-full"},"phaseValue":0.5271626432772403,"angle":2.1990735294888193,"next":{"value":1717076698261.5,"date":"2024-05-30T13:44:58.261Z","type":"thirdQuarter","newMoon":{"value":1717714558956,"date":"2024-06-06T22:55:58.956Z"},"fullMoon":{"value":1718990280345,"date":"2024-06-21T17:18:00.345Z"},"firstQuarter":{"value":1718352419650.5,"date":"2024-06-14T08:06:59.650Z"},"thirdQuarter":{"value":1717076698261.5,"date":"2024-05-30T13:44:58.261Z"}}},"zenithAngle":82.07414407481025,"times":{"rise":"2024-05-24T21:45:16.450Z","set":"2024-05-24T03:49:56.069Z","alwaysUp":false,"alwaysDown":false,"highest":"2024-05-24T12:47:36.259Z"},"positionAtRise":{"azimuth":2.4110902793848616,"altitude":0.0037763630712496594,"azimuthDegrees":138.1452970337711,"altitudeDegrees":0.21636966589166687,"distance":385234.2249828217,"parallacticAngle":-0.48894960950229566,"parallacticAngleDegrees":-28.014749019051234},"positionAtSet":{"azimuth":3.928591365849633,"altitude":0.0030079180325627885,"azimuthDegrees":225.0917046947195,"altitudeDegrees":0.1723410083871419,"distance":388773.20643887366,"parallacticAngle":0.5142043676908113,"parallacticAngleDegrees":29.461740075876637},"highestPosition":{"azimuth":0.06278820271705365,"altitude":-1.1374260162897294,"azimuthDegrees":3.597499018899023,"altitudeDegrees":-65.16971024177992,"distance":387010.99659302,"parallacticAngle":-0.043920524934587556,"parallacticAngleDegrees":-2.516460712750963},"altitudePercent":60.22190216263237,"isUp":false,"pos":[],"posChanged":false},"topic":"moon"}

Any details on what error you get?

Just the Node error when you write garbage into a function and it stops you deploying

I get no such error

image

what version of Node-RED are you using?

Show us a screenshot please.

As already replied - after rebooting Node-Red, I no longer have an issue.

Node-Red v 3.1.9

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.