Hello,
I hope you can help me track my water consumption correctly.
First I declare a snmp sensor which monitors a counter (counter increases by 1 for each liter consumed).
- platform: snmp
host: a.b.c.d
baseoid: .1.3.6.1.4.1.31440.10.7.1.1.9
name: cold_water_counter
Then I use this counter and create statistics for it. I am only interested in the very last delta, so sampling_size is set to 2:
- platform: statistics
entity_id: sensor.cold_water_counter
name: stat_cold_water_counter
sampling_size: 2
Then I declare a sensor which monitors the ‘change’ attribute from the statistics platform:
- platform: template
sensors:
cold_water_delta:
value_template: "{{ state_attr('sensor.stat_cold_water_counter_mean','change') }}"
What I have found out is that new values are only added to “cold_water_delta” when there is a new and different value in the attribute ‘change’ of ‘sensor.stat_cold_water_counter_mean’.
Can someone tell where in the code this behavior is defined?
Is there a way to change the behavior and trigger on every update (regardless if it is a new or same value)?
My plan is then to feed ‘cold_water_delta’ into a utility meter. Right now this does not work as almost all updates are ‘1’ indicating exactly 1 liter of water was consumed. No matter how many '1’s are sent, utility will only see the first…
(I wonder how accurate the utility meter really is… Does it assume a fixed and constant update rate? Unless I miss something, whenever the monitored sensor changes value, ‘_state’ is increased, and the sum of all such changes is eventually read out as ‘last_period’. Double the rate and you double the result, no? I would expect to add ‘time’ x ‘value’ and not just ‘value’ )
Thank you