I have Phantom retractable screens on my patio. They are supposed to be raised if wind speed is above 25 mph. I use a Tempest weather station in my yard to monitor wind speed. My automation will raise the screens (via ESPSomfy RTS) if it sees a wind gust over 20mph. The problem with that is there are sometimes spikes in the data. I might see wind gusts around 15 mph but then 1 split second wind gust above 20mph. I can’t use a trigger duration in the automation because the gust may not last very long.
I’d like to set my automation to raise the screens if it sees 2 wind gust readings over 20mph in a 10-minute period. Is there a way to do that?
What about something like:
alias: Count Wind Gusts
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.wind_gust
above: 20
id: increment
- platform: numeric_state
entity_id: sensor.wind_gust
below: 20
for: "00:10:00"
id: reset
condition: []
action:
- service: counter.{{trigger.id}}
data: {}
target:
entity_id: counter.wind_gust
mode: single
You could do the same kind of thing in a trigger-based template sensor as well.
template:
- trigger:
- platform: numeric_state
entity_id: sensor.wind_gust
above: 20
- platform: numeric_state
entity_id: sensor.wind_gust
below: 20
for: "00:10:00"
id: reset
sensor:
- name: gust_counter
state: |
{% set current = this.state | int(0) %}
{% if trigger.id == reset %}
0
{% else %}
{{ current + 1 }}
{% endif %}