I have defined a template sensor which derives its state from another sensors attribute like this:
- platform: template
sensors:
cat_feeding_change_wet:
friendly_name: "Katze Nassfutter"
unique_id: cat_feeding_change_wet
unit_of_measurement: "g"
value_template: >-
{% set feeder_status_attr = state_attr('binary_sensor.pet_cat', 'status') %}
{{ feeder_status_attr.feeding.change.0 | float }}
The attribute and therefore the template sensor show the last value all the time. But I would like to have that values for a limited amount of time (e.g. 60s) and set it to zero afterwards. This way I could easily graph the sensor and see when the cat was eating.
I already tried this automation, but it didn’t work.
- id: "1723382696795"
alias: Reset feeding values
description: ""
trigger:
- platform: numeric_state
entity_id:
- sensor.cat_feeding_change_dry
- sensor.cat_feeding_change_wet
for:
minutes: 1
above: 0
below: 0
condition: []
action:
- service: python_script.set_state
data_template:
entity_id: "{{ trigger.entity_id }}"
state: "{{ float(0) }}"
mode: single
What would be the best way to do this using manual yaml code? Idealy with the ability to list multiple entities to be set to 0.
I’m asking for manual yaml, because I have a bunch of those template sensors and this would allow me to adapt them by search&replace.