In the past I manualy wrote down the first of every month the value of my ulility meters and imported the data in an app on my smartphone. There I got this graph:
Now I have bought the Homewizard P1 meter for our digital utility meters. Now I can see in “real-time” the consumed power/gas/water.
Now I was thinking to automate this. I have already installed Influx, Node red on my Home Assistant and used them in the past but my XP is limited.
I don’t know where to start…I was thinking to use the old data and import this in Influx so that I get the above graph but now would like to automaticaly import every first of the month import the meater reading.Any ideas ?
You could use the influxdb integration to automatically write your values to the influxdb. You can find more info here: InfluxDB - Home Assistant You don’t need node-red for that. But if you only want to write values once per month you could of course do that with node-red.
For displaying the graph I think that the grafana addon is very suitable. In Grafana you can define a data source (your influxdb) and then make queries for the data you want to see, like the example below:
However, that is writing values continuously, not only once per month. In Grafana I made a query that subtracts the first counter value from the last counter value in a month leaving you with the amount of that month.
If you only want to write a value once per month with node red you would need something like this:
The “Big timer” node is not a standard node in node-red, but you can add it very easy through import. It has a lot of features (most you won’t need). One of those is that it can trigger on a specific day each month what is what you would need.
With the second node “read P1 counter value” you get the value from your P1 meter. That is then passed along to the function “node” in which you make InfluxQL query to write the data to influx. The actual writing is done in the last node “run query”.
Probably your P1 meter is giving you a cumulative value. That means, that in the end you would still need to subtract 2 values to get the usage of a month. In that case I think the first method of writing data continuously is easier. Only downside is that you will be missing out on the node-red fun
Last night I was busy with Influx and Node-red. I successfully read data from the Influx DB with Node-red, writing is something I still have trouble with.
You are right that at the end, I still have to subtract the two values with the Node-red.
You mention that you use Grafana can subtract the values there with a query. This was unknown to me, so I have to look into this too. It seems easier than using Node-red? Thanks for your help
I understand that you also use a function in Grafana to calculate the differende between two values?
Is this done by using transform data, or how does it work?
One word of caution: once you click and enter a query, in most cases you can’t easily switch back.
In the query you can see that it asks for the last value of value: last(“value”) and subtracts the first value of value: first(“value”). The field value is here the counter value. In this case it’s from a domoticz measurement called “Gas-usage”. For home assistant it would be “m3”. And “name” would be “entity_id” or “friendly_name”.
With the GROUP BY time(1d) you can control the interval. One big disadvantage: it doesn’t seem to be possible to group by month. Instead you’ll have to use 30d or something similar.