Shelly Plus 1PM Nodered Select Data?

Hi,

i have bought Shelly Plus 1PM 2Gen. to measure my Solarpower with Grafana on my Raspberry Pi.

I have installed MQTT and Node-Red on my Raspberry and created a Node

ShellyPlus1PM/status/switch:0

I get this Data from the Shelly with a Debug Node:

{"id":0, "source":"init", "output":false, "apower":0.0, "voltage":233.9, "current":0.000, "aenergy":{"total":0.000,"by_minute":[0.000,0.000,0.000],"minute_ts":1665655079},"temperature":{"tC":52.3, "tF":126.2}}

But how can i select a Single Data Source like "voltage" or "apower" ?

I have seen some Tutorials on Youtube with Shelly 1PM (i think 1Gen) it was easyier to select the Single Data.

Use the debug node and sidebar to get the path, using the copy path button next to voltage. It appears when you hover the mouse to right of property name.
it should be msg.payload.voltage. if you use the copy path method you will get payload.voltage, you would then append msg. to front if using it in a function node.

I want to get this Data to Influx Database.

msg.payload.voltage
msg.voltage

I gettin undefined in both variants

Feed the message into a debug node and screenshot so we can check what you have. You can paste an image here. Also show us how you are trying to access it that is getting undefined and how you know it is undefined.

Ok, here we go


Just a thought... is your MQTT-In node set to output a parsed JSON object?

parsed

This is a Gen 2 device so the topics are different to gen 1
e.g. topic would be something like
<shelly-id>/events/rpc

Ok now Debug Output works, but not the InfluxDB Data Output

I have changed the Output to "a parsed JSON Object"

Now i gettin from Influx Database a boolean Error

Change the debug node to show msg.payload, see what is there, then check that the layout of the payload is correct for the influx node. The help text for the influx node tells you what is allowed. Note that nested objects are not allowed in influx. You must decide what fields and tags you want in the database and build the payload accordingly.

Write to InfluxDB now works but no single values only the whole String:

{"id":0, "source":"init", "output":false, "apower":0.0, "voltage":235.2, "current":0.000, "aenergy":{"total":0.000,"by_minute":[0.000,0.000,0.000],"minute_ts":1665678358},"temperature":{"tC":52.6, "tF":126.7}}

How can i preformat it to write Single Datas ?

You should have the parse JSON box ticked in the mqtt node. Then you must decide which fields and tags you want to write.

If i use the parsed JSON Object in MQTT Node and add to the InfluxDB Node Measurement -> voltage

I get this Error:

Error: A 400 Bad Request error occurred: {"error":"unable to parse 'voltage aenergy=[object Object],apower=0,current=0,id=0,output=false,source=\"init\",temperature=[object Object],voltage=232.5': invalid boolean"}

That is because you have not formatted the payload as required by the node. Have you read the help text and decided what fields and tags you want? If you don't know what influx fields and tags are then you need to read the influx docs.

Ok thanks i have read a while :grinning:

In the meantime I managed to get a few values ​​into the database. I'm a complete newbie here.

How can I set time interval for inserting into the influxdb?

As you have it, it will add a record each time new data arrives via MQTT. If you want to slow that down (or speed it up) then you could change the rate at which the publishing device sends data. Alternatively to slow it down you could configure a Delay node configured in Rate Limit mode, with Drop Intermediate Messages.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.