I'm a Java noob and I have spent an hour googling to try to figure out how I access the value 125.5 in a payload represented below. I tried payload.solar_power.value and payload.solar_power['value'] but no luck. I don't know what to search for to find the answer or I wouldn't be asking.
Note: this is part of the output from a Join node. msg.payload.solar_power gives me "{"value": 125.5}" but I don't know the proper way to access the number.
And here's two screen shots that may give you everything you need, I hope... I'm sure this is a first-day-of-class thing to know and I'm embarrassed it's taking me so long to figure it out.
If I pass my version through a json parser node set to create a javascript object from msg.payload.solar_power it gives me a valid msg.payload.solar_power.value.
This is a fudge though and it's much better to fix the data at it's origin.
How did your data get in this state in the first place?
Is it bad code inside the function or something odd coming from an API?
I suspect the function, only because I see it has multiple input wires.
Why all these "value" property names? Perhaps the original data also had "units".
If you show us your function code we may be able to fix it.
Turns out the data input node, from MQTT, was set to output as "a String" instead of auto-detect. It is now outputting a parsed JSON object and everything is working nicely so far.
Thanks for your response. Next time I'll post actual data as requested.
Data source is from MQTT (on a RaspPi running Victron Venus OS), the node was set to output as "a String" instead of JSON auto-detect. I'd set it that way while goofing around trying to get this, my first flow, working. Got wrapped up in my underwear and couldn't undo what were probably multiple problems.
Today I fixed the root problem and cleaned up the flow and now it will actually trip a Shelly 1+ relay to turn on and off a fan on my desk based on the real-time status of spare solar power available. Eventually I'll have it controlling my RV fridge so that when the sun goes down, the fridge auto-magically switches from AC-power-inverted-from-solar to running off of propane instead.
This means I won't wake up in the mountains to empty batteries and no power at all if I forget to manually switch from AC power to propane in the evenings.