Hi,
I’m rather new to HA but was able to realize many ideas.
Unfortunately, I’m now struggling with an probably very easy question: How Can I reset the value of an sensor every night?
Some background: I want to calculate the efficieny of my solar panels in the format kWh/kWp.
For this I have created a sensor called “NO_Effizienzmultiplikator” that gives me exactly this value. The example given is just for one of the panels.
The problem is that sensor.no_erzeugung_kwh was created as a Riemann sum integral (left) helper. Unfortunately it does not start from zero every day but just adds the yield from the next day on top.
Therefore I thought I could use an automation that resets the sensor value every night. But this piece of code doesn’t work.
alias: NO & SO Erzeugungszähler auf Null setzen um Mitternacht.
description: ""
trigger:
- platform: time
at: "00:00:00"
condition: []
action:
sensor:
name: "NO Erzeugung kWh"
state: "{{ 0 }}"
As soon as I click the Save button I get the following error message:
“Message malformed: Unable to determine action @ data[‘action’][0]”
It’s probabaly a stupid coding error? Please advise.
PS: I also tried to store the current value of the helper in a variable at midnight and then to subtract it the next day from the helper value which continues to increase. But here I was also struggling. Didn’t manage it to store the value…
Thanks for your clear explanation. As a nearly newbie with HA, I am missing your sentence “Then, utilities” just before your code with the cron time.
Which part of HA can I include this? Do I have to create a section “utilities.yaml” and insert the code in there?
Thanks for any light you could help me with.
Thanks a lot for your swift answer. I’ll implement the way you are showing.
What I don’t get is why am I having the 11 kWh vertical front when my swimming pool pump is starting (it is a 1.2 HP)
This data is coming from a Riemann sensor (see below) fed by the instant power delivered to the pump (through a zigbee double current sensor). The Riemann sensor is not reset to zero every day which is causing the data to be collected wrongly.
The Riemann sensor is an integral sensor.
It will always increase, so the need for the utility_meter.
To make it simple:
The utility_meter will always take the difference between the last reset and now. So it will be 0 at midnight and increase “slowly” during the day to go back to 0 at midnight again (for a daily)
The Riemann sensor is doing the integral under the curve of a instantaneous sensor
a. The sensor used by the Riemann sensor is supposed to be something going up and back to 0. You can “visualize” it like generating a continuous histogram.
b. The Riemann sensor will then sum those histograms to give a total of consumption, growing over time, forever. It will never go back to 0.