Json Data Pushed from Inverter

Hi, I have successfully got json push data from my Fronius inverter data manager. But I am having issues trying to get the required information formatted as I want to control some tasmota switches.
This is a copy of the json that comes from the inverter, it has "pin 0" to "pin 9", what I want is the set value of each pin so they can all seperatly control different tasmota switches.

{
   "pin 0" : {
      "direction" : "out",
      "function" : "EVU_FEEDBACK",
      "set" : false,
      "type" : "DIGITAL"
   },
   "pin 1" : {
      "direction" : "out",
      "function" : "EMRS_OUTPUT_1",
      "set" : false,
      "type" : "DIGITAL"
   }
}

I would really appreciate some help if possible.

msg.payload['pin 0'].set

That is how you get the value.

Thanks, heaps I had tried that and I get a TypeError: Cannot read property 'set' of undefined

Then your output is not equal to the object you posted above (i assume msg.payload)

Reference:

https://nodered.org/docs/user-guide/messages

here is the debug output

Read the link above.

That’s a very odd looking object.

Can you expand the debug message out and show us a screenshot please. As @dceejay said, it looks odd.

It looks like it’s an object with one really long key that is a json string, and value an empty string.

1 Like

Yep.

I suspect some bad function code and/or some incorrectly JSON nodes placed in his flow somewhere.

@Bigben83 show us your flow.

here is a copy of the flow. its a simple http get request, -> function -> debug.
till I get the required data.

[{"id":"1a89928.9cf4b6e","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"59c4fe7c.2b9f7","type":"http in","z":"1a89928.9cf4b6e","name":"","url":"/datamanager_io","method":"post","upload":false,"swaggerDoc":"","x":160,"y":60,"wires":[["4b814275.70a11c"]]},{"id":"4b814275.70a11c","type":"function","z":"1a89928.9cf4b6e","name":"pin 0 status","func":"msg.payload[['pin 0'].set];\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":60,"wires":[["7cde0a0f.e660f4"]]},{"id":"7cde0a0f.e660f4","type":"debug","z":"1a89928.9cf4b6e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":60,"wires":[]}]

Here is a full scren shot of the debug screen

it is odd but thats how the fronius inverter sends it. I could attach a copy of a json file if you want to see.

Is that debug message straight out of the http request node?
If not, can you show us that?
Also, what settings do you have on the http request node?

Ps, there is an easy fix but need to see the above additional info first.

see this screenshot

Ah so it's not a http request but an endpoint. What calls your endpoint? Is it another flow in your node-red that calls the endpoint? If so can you show us that?

Its a push service from the fronius inverter itself

Ok. Understand.

So a workaround is to get that key and pass it through a JSON node to make it an actual JS object.

Do you know how to do that?

Not sure I do sorry

I believe @Steve-Mcl meant to put the JSON node between the http request and function nodes.

No. You can't do that (I think). The JSON is the object key so you have to get the key of the object (hint Object.keys()) then pass the key through a JSON node.

Something like...

var k = Object.keys(msg.payload)[0];

I'll jump on a computer in a bit & show you a demo but try yourself in the meantime.

Ah so it seems. Sorry for adding confusion!