# Json Data Pushed from Inverter

**URL:** <https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962>\
**Category:** General\
**Created:** [20 May 2020 00:57 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962 "2020-05-20T00:57:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 00:57 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/1 "2020-05-20T00:57:23Z")

</div>

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.

```auto
{
   "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.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [20 May 2020 05:39 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/2 "2020-05-20T05:39:49Z")

</div>

```auto
msg.payload['pin 0'].set

```

That is how you get the value.

---

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 05:52 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/3 "2020-05-20T05:52:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [20 May 2020 06:06 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/4 "2020-05-20T06:06:51Z")

</div>

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

Reference:

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 06:17 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/5 "2020-05-20T06:17:02Z")

</div>

here is the debug output

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/89068aa12312cf7370d730b9b62ea89d791e9ac4.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [20 May 2020 06:30 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/6 "2020-05-20T06:30:58Z")

</div>

Read the link above.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [20 May 2020 06:37 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/7 "2020-05-20T06:37:36Z")

</div>

That’s a very odd looking object.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2020 07:00 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/8 "2020-05-20T07:00:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [20 May 2020 07:07 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/9 "2020-05-20T07:07:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2020 07:20 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/10 "2020-05-20T07:20:17Z")

</div>

Yep.

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

@Bigben83 show us your flow.

---

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 07:37 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/11 "2020-05-20T07:37:45Z")

</div>

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

```auto
[{"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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b488dafbeee0570f31039400a8b5c6bce7429cb.png)

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2020 07:43 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/12 "2020-05-20T07:43:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 07:46 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/13 "2020-05-20T07:46:33Z")

</div>

see this screenshot

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5989c8b5a2274b1ae1dc746626d119e2f7e92ad.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2020 07:48 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/14 "2020-05-20T07:48:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 07:51 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/15 "2020-05-20T07:51:46Z")

</div>

Its a push service from the fronius inverter itself

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/b/4b580e36031d87e9cdb6e6ce502e8438c1d42592.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2020 07:57 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/16 "2020-05-20T07:57:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Bigben83](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bigben83](https://discourse.nodered.org/u/Bigben83)\
**Post date:** [20 May 2020 08:03 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/17 "2020-05-20T08:03:13Z")

</div>

Not sure I do sorry

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75bf6e4944f337b357735029b521c6178ef34751.png)

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [20 May 2020 08:13 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/18 "2020-05-20T08:13:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 May 2020 08:20 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/19 "2020-05-20T08:20:12Z")

</div>

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...

```auto
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.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [20 May 2020 08:26 UTC](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962/20 "2020-05-20T08:26:10Z")

</div>

Ah so it seems. Sorry for adding confusion!

[Next page](https://discourse.nodered.org/t/json-data-pushed-from-inverter/26962.md?page=2)
