Hi @Colin , could you write me the function what would decode values from below respond:
{"_msgid":"6e52e585.d00a6c","timestamp":1623433951765,"statusCode":200,"headers":{"date":"Fri, 11 Jun 2021 17:52:32 GMT","server":"Apache","access-control-allow-origin":"*","access-control-allow-headers":"*","vary":"Accept","x-rate-limit-limit":"1000","x-rate-limit-remaining":"999","x-rate-limit-reset":"3","access-control-allow-credentials":"false","set-cookie":["_csrf=d4tZYLe-lb9jnWujx8DIuSIcAWxfm_QB; path=/; secure; httponly"],"x-frame-options":"sameorigin","content-length":"170","connection":"close","content-type":"application/json; charset=UTF-8","x-node-red-request-node":"7e6b7728"},"responseUrl":"https://api2.tigoenergy.com/api/v3/data/summary?system_id=52705","payload":"{\"summary\":{\"lifetime_energy_dc\":\"834644.65666667\",\"ytd_energy_dc\":\"834644.66\",\"daily_energy_dc\":\"14931.71\",\"last_power_dc\":458,\"updated_on\":\"2021-06-11T18:39:00+01:00\"}}","redirectList":[],"responseCookies":{"_csrf":{"path":"/","value":"d4tZYLe-lb9jnWujx8DIuSIcAWxfm_QB"}}}
from payload I am looking for:
lifetime_energy_dc
ytd_energy_dc
daily_energy_dc
last_power_dc
I am injecting the timestamp so this can be use by InfluxDB to place it in time.
Colin
11 June 2021 21:13
43
Sorry, I am away at the moment and unable to contribute.
No rush @Colin . Whenever you have a moment.
Colin
12 June 2021 10:24
45
Have you tried to work it out yourself?
As I mentioned before I have no programming experiences at all. Some simple changes in the code are not the problem but this is a bit too complicated.
Send this thru a json
node and look at the output
I tried to send this to InfluxDB as json but getting error:
receiving in json:
{"_msgid":"aa87fcac.5b45","timestamp":1623532528259,"statusCode":200,"headers":{"date":"Sat, 12 Jun 2021 21:15:28 GMT","server":"Apache","access-control-allow-origin":"*","access-control-allow-headers":"*","vary":"Accept","x-rate-limit-limit":"1000","x-rate-limit-remaining":"999","x-rate-limit-reset":"3","access-control-allow-credentials":"false","set-cookie":["_csrf=JnmKc8FCTpdEKHGIn6lu-30nWcoj_ABR; path=/; secure; httponly"],"x-frame-options":"sameorigin","content-length":"168","connection":"close","content-type":"application/json; charset=UTF-8","x-node-red-request-node":"479acce0"},"responseUrl":"https://api2.tigoenergy.com/api/v3/data/summary?system_id=52705","payload":{"summary":{"lifetime_energy_dc":"859723.86666667","ytd_energy_dc":"859723.87","daily_energy_dc":"24233.87","last_power_dc":0,"updated_on":"2021-06-12T21:36:00+01:00"}},"redirectList":[],"responseCookies":{"_csrf":{"path":"/","value":"JnmKc8FCTpdEKHGIn6lu-30nWcoj_ABR"}}}
getting error:
TypeError: points.forEach is not a function
Please help me to capture values from
payload -> Summary ->
lifetime_energy_dc:
ytd_energy_dc:
daily_energy_dc:
Sorry, I was refering to your trying to get the data from msg.payload. In the sample data you provided. What you provided msg.payload is a string representation of an object so you need feed it thru a json
node to turn it into an object. Then you will be able to address the data.
Thereās a great page in the docs that will explain how to use the debug panel to find the right path to 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.
https://nodered.org/docs/user-guide/messages
system
Closed
26 June 2021 21:36
50
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.