I finally managed to get my Utility sensors working as they should, but what is the best way to get the cost of the persistent data sorted from a utility sensor please?
sensor
- platform: integration
source: sensor.tv_power
name: tv energy
unit_prefix: k
round: 2
I thought it would be like this but it appears to just add it up and not sure how I should be going about it? as when I reboot HA the sensor shows 0 (see the graph drop)
Sensors aren’t persistent across reboots. You could create an input_number to store the value. If you don’t set an initial value, it will be persistent.
Then you need to store the values. A easy way would be to store the current sensor value on home Assistant restart or shutdown event.
Now add this input_number as an offset in your sensor.
Easiest thing would be to update the input number when home Assistant reboots. Home Assistant sends an event on reboot that you can use as an automation trigger.
A different DB is the solution, as you’ve found out. InfluxDB is certainly one possible solution.
I’m using emonCMS: Emoncms · GitHub
That is an energy monitoring tool designed for everything electricity related. I’ve got CT sensors feeding data into a different Pi running emonCMS and then sends data to HA.
You seem to have HA already set up with sensors, you can send data from HA to emonCMS. Then set up the feeds in emonCMS, it will save all data permanently until you go to delete stuff. There’s also a handy data trim tool, for example to delete years old data.
You can use their emonPi, which is their solution that works straight out of the box: https://openenergymonitor.org/
Nice bit of kit, though a bit expensive at ÂŁ200.
(okay, just had another look, no enclosure unassembled is more reasonable at ÂŁ105, 1 less CT sensor but otherwise comparable to my setup)
For me, after upgrading to Pi 4 for Home Assistant, I’ve got a 3B to spare. So I bought this CT sensor hat with their matching CT *3 and voltage sensors, £51, put it on my old Pi 3 running emonPi image.
Yes. In emonCMS, any input is listed in the “Input” table, this includes stuff from HA. In the Input table, you can do loads of things with it. There is a kwh converter, a kwhd (kwh day) converter, you can do calculations on your data, even with another input (eg. grid + solar = house consumption). The last bit means you can create a cost of electricity use by multiply with your per unit cost.
All the results can be fed into a “Feeds” table. From that table, you can get the data into HA or into their other tools, such as “apps” or graphs.
If you are in UK, I’ve just discovered there is an “app” that can match your usage against Octopus Agile smart tarrif that changes every 30min. Looks like my average unit rate would only cost 6.2p per kWh if I were on Agile.
Depend on your meter location, it might be difficult getting somewhere to plug in. I was fortunate enough to have the meter my study (formerly garage), next to some power sockets.
Let me know if you need any help setting everything up. The emonCMS interface takes some getting use to. My initial mistake is making too many feeds for calculations, whereas everything should be done on the input page. Each step that does calculation will output into the next row.
I can vouch for the EmonCMS, I got the RPICT3V1 last week and have spent today calibrating it and integrating in to HA. Works really well I just need to create a dashboard display now.
as I was saying to papasierra, I think I cocked up big time. I spent all day today doing this but I did’t buy the voltage sensor, as I thought it wasn’t needed or I could use any AC.DC adapter I have lying around… WRONG
Oh dear, I hope you haven’t damaged the board, It should be a AC to AC power supply not AC to DC.
I had a mains transformer around that gave out 10v so used that and recalibrated the VCAL as in the link earlier.