when using the integration component you need to reset it yourself otherwise it continus counting forever (or until a restart if you don’t restore values).
The sensor.integration.reset action is what you need - probably together with a script so you can time your hourly / daily / etc. resets
I’m having some issues integrating this code with my current pulse_counter sensor.
template:
- sensor:
- name: Rainfall today
unit_of_measurement: mm
state_class: total_increasing
unique_id: rainfall_today
state: >-
{% set count = states('sensor.rainsensor_flips') | int(0) %}
{% set mm = count * 0.30303 %}
{% if count >= 0 %}
{{ mm|round(1, 'floor') }}
{% endif %}
# If you have issues with the history sensor doubling after restarting HA, add the line below (@BigG)
availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"
How can I adapt this to be compatible with my Pulse Counter?
Also, I dont want to do any calculations in this template sensor, as the calculations are all done on the pulse_counter.