Pulling data from payload

Hi,

I have a Node Red node for AlphaESS inverters. This connects into a cloud service and pulls relevant data from the inverter. This part works correctly.

The node returns a payload as follows:

image

What I want to do is take each of these values, and plot them to a sensor node, so that it shows up in Home Assistant.

Any ideas as to how I can do this? I got as far as the node + a switch, and can’t figure out how to take each reading separately.

Thanks.

You can connect output of your node directly to Entity node, configured to be a sensor.
Node red will create all sensors for you.

Here is an proof of concept using inject node istead of your node which produces mentioned by you json object

[{"id":"29405a733b05159f","type":"inject","z":"d36bc71f.81d9c8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"consumption\":733.572,\"battery\":{\"soc\":52,\"load\":100}}","payloadType":"json","x":330,"y":100,"wires":[["36b4bea2a447c8be","b6a44a9d60cf6303"]]},{"id":"36b4bea2a447c8be","type":"ha-entity","z":"d36bc71f.81d9c8","name":"test_battery_soc","server":"6cdd0bc8.b8e434","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"test_battery_soc"},{"property":"device_class","value":"battery"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"%"}],"state":"payload.battery.soc","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":610,"y":120,"wires":[[]]},{"id":"b6a44a9d60cf6303","type":"ha-entity","z":"d36bc71f.81d9c8","name":"test_consumption","server":"6cdd0bc8.b8e434","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"test_consumption"},{"property":"device_class","value":"energy"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"kWh"}],"state":"payload.consumption","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":620,"y":70,"wires":[[]]},{"id":"6cdd0bc8.b8e434","type":"server","name":"HA MaXyM","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

You need to create and configure each sensor manually (AFAIK there is no way to configure them in generic way, based on incoming data). Example above shows more or less how to do that. See that state field has to contain a ‘path’ to particular attribute from your json

And there are sensor device classes you can chose from

1 Like

That’s it!

Thanks very much!

Have you also looked at :

GitHub - DasLetzteEinhorn/AlphaESS_Monitor_Hass ?