The following automations has two triggers:
- one if outside temperature goes above 20
- one if outside temperature falls below 15
It turns on a switch (you smart plug), if temperature is above 20 and off otherwise. Since the automation only triggers on passing the thresholds 15/20, the switch will stay unchanged if temperature is between 15-20.
Replace <your-weather-entity>
and <your-plug-entity>
with appropriate values, of course.
alias: Fan Control
description: 'Turns plug on, if temperature is above 20°C, off otherwise'
mode: single
trigger:
- platform: numeric_state
entity_id: weather.<your-weather-entity>
attribute: temperature
above: '20'
- platform: numeric_state
entity_id: weather.<your-weather-entity>
attribute: temperature
below: '15'
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: weather.<your-weather-entity>
attribute: temperature
above: '20'
sequence:
- service: switch.turn_on
data: {}
entity_id: switch.<your-plug-entity>
default:
- service: switch.turn_off
data: {}
entity_id: switch.<your-plug-entity>