I have a kWh meter which sends it data via modbus - ESP/Tasmota to HA. All works fine and I added the sensor to my energy dashboard.
The energy dashboard is able to calculate the monthly usage.
My question is if it is posible to send an message (notify) via Email every 1st of the month with the begin, end and total usage values of the previous month?
I tried to understand Jupyterlab, but this is to much for my brain to grasp. ChatGTP proposed a template sensor, but also here no luck. Perhaps a script which queries the database… Since the energy dashboard is able to get the values, it should be doable?
Does anyone has a clue how I can solve this problem?
Don’t use ChatGPT. It is trained on out of date information and will only confuse you.
The energy dashboard calculates these values from the statistics database when they are needed for display. There are no actual entities that hold these values. You will have to create an entity to track the value. The Utility Meter helper with a monthly cycle can track how much energy was used each month but will not be able to tell you the starting value.
I’m doing something similar for every month.
in templates.yaml I use the following template to write the consumed energy value to an input_number helper, every first day of the month at midnight.
I made a helper and a template for every month.
the value comes from an attribute from a utility meter with monthly reset.
this attribute is called “last_period” and holds the value from the previous month.
this way you have the end (and start) value for every month.
with these values you can do anything you want, make further calculations, send notifications, etc…
the trigger does not have to be at midnight because the value is available during one month. (I tend to do this one minute after midnight)
the example below is for the month november:
the next time this template will trigger will be at the 1st second of the new month (december in this case).
so yes the value will be written to input_number.energy_consumed_12.
So, I want to give a small follow-up of my journey.
After some fiddling around in HA, tried en after that decided to go the node-red route. Every month Node-red pulls the data from the kWh meters and stores it in a sqlite database.
After that It creates a PDF with all data for my administration.
For those who want to replicate this, I can provide the json flow for node-red. I think that the only node-red-contrib-pdfmake2 and node-red-contrib-moment have to be installed (hamburger-menu - manage pallete).