How to set measurement for node-red

I have a pulse count electricity meter reader which works well, but I want to only take a meter reading once per month. I figured this out using a cronplus node addition. I then want to place this once per month reading into InfluxDB.

I have looked at the instructions in various places but cannot figure out how I set up “measurements”. As a trial I have used an inject node and debug to get the reading from HA, which returns a correct value. But I just cannot understand how I have to then setup the payload etc, so it will then put into InfluxDB. (I can configure the appropriate access to InfluxDB ok - no problems with that)

I just seem to be going round in circles. I have looked at exampled but this is mainly script, which is just so confusing. Does/can anyone to tell me how to set up the Node-Red flow to achieve this. I know I am so close but a lot of the functions don’t make much sense, even after reading much of the info.

As you can tell, I am not that proficient coding.

It looks like it can’t find the db. In the influx config what ip are you using? The default 127.0.0.1? Try with home assistant’s ip address.

I copied the address from the HA InfluxDB setup page - a0d7b954-influxdb.

Looking at the InfluxDB explorer after I trigger an inject I do get the meter reading value showing.

So do I deduce that I have set up the “current state” node correctly?

I tried 127.0.0.1 but this is the error I found:

rror
name: “Error”
message: string
A 404 Not Found error occurred: {“error”:“database not found: "database"”}
stack: string
Error: A 404 Not Found error occurred: {“error”:“database not found: "database"”}

at IncomingMessage.<anonymous> (/opt/node_modules/influx/lib/src/pool.js:50:38)
at IncomingMessage.emit (node:events:520:35)
at endReadableNT (node:internal/streams/readable:1729:12)
at processTicksAndRejections (node:internal/process/task_queues:90:21)

Use the ip address of your home assistant without :8123. Not the influx page. Use the IP and not the mdns address/host name.

I got rid of the error messages and I am getting info from the sensor but I am confused about formatting the sensor data to get it into influxdb v1.0.

As you can see the debug info is OK and returning values, but when I look at InfluxDB explorer I see no info an the query, so I guess it is just the formatting of the info that is necessary.

I will keep reading, but I am struggling, can anyone help with suggestions how I need to format the data to go into InfluxDB Please?

You can find the format here.

https://flowfuse.com/node-red/database/influxdb/#step-4%3A-write-the-data-point-to-influxdb

1 Like

It is very embarrassing but I am really struggling with this. I have the flow working in the Node-Red but after looking at multiple YouTube tutorials and other instruction manuals on Node-red website I just cannot understand what information I need to “change” in the node to get it accepted by InfluxDB.

There is lots of info about generating this random number and that random number in JSON, but nothing for taking the reading from an actual entity and changing it to be accepted by InfluxDB.

Can someone please explain in simple language what I need to change and into what. I have very little JSON knowledge and maybe this is why I am struggling.

This is the current flow:

This is the expression for the current state node:

Any help greatly appreciated, but please keep simple for my lack of understanding.