I would like to trigger a rule if the temperature rises twice in a row by 2°C within 10 seconds.
Is there a good way to realize this?
I would like to trigger a rule if the temperature rises twice in a row by 2°C within 10 seconds.
Is there a good way to realize this?
The following should do what you want, but it requires new features in the 0.113 release (which hopefully will be available tomorrow.)
counter:
temp_up_count:
automation:
- trigger:
- platform: state
entity_id: sensor.TEMP
mode: restart
action:
# Did temp rise by two?
- choose:
- conditions:
- condition: template
value_template: >
{{ trigger.to_state.state|float - trigger.from_state.state|float < 2 }}
sequence:
# Did not rise by two, so reset counter.
- service: counter.reset
entity_id: counter.temp_up_count
default:
# Did rise by two, so increment counter.
- service: counter.increment
entity_id: counter.temp_up_count
# Did it rise by two twice within 10 sec?
- choose:
- conditions:
- condition: numeric_state
entity_id: counter.temp_up_count
below: 2
sequence:
# Did rise by two, but not twice within 10 sec.
# Reset counter if there is not another temp change within 10 sec.
- delay: 10
- service: counter.reset
entity_id: counter.temp_up_count
default:
# Did rise by two twice within 10 sec!
- ...