Now that the heat has finally hit the UK I have set up my bedroom fan to switch on via a 433mhz switch then turn off at set times depending on the bedroom temperature. Only issue I have is that I have 4 different automations for each temperate range. Is there a way of nesting them all into 1 automation ?
alias: Bedroom Fan off 23:00
trigger:
platform: time
at: '23:00:00'
condition:
condition: numeric_state
entity_id: sensor.bedroom_temperature
below: 23
action:
service: homeassistant.turn_off
entity_id: switch.bedroom_fan
alias: Bedroom Fan off 23:30
trigger:
platform: time
at: '23:30:00'
condition:
condition: numeric_state
entity_id: sensor.bedroom_temperature
below: 24
action:
service: homeassistant.turn_off
entity_id: switch.bedroom_fan
alias: Bedroom Fan off 00:00
trigger:
platform: time
at: '00:00:00'
condition:
condition: numeric_state
entity_id: sensor.bedroom_temperature
below: 25
action:
service: homeassistant.turn_off
entity_id: switch.bedroom_fan
alias: Bedroom Fan off 06:00
trigger:
platform: time
at: '06:00:00'
condition:
condition: numeric_state
entity_id: sensor.bedroom_temperature
above: 24
action:
service: homeassistant.turn_off
entity_id: switch.bedroom_fan
I don’t understand what you are trying to do with your conditions, but you can add multiple time triggers to one automation like this:
- alias: test
trigger:
- platform: time
at : '11:00:00'
- platform: time
at : '12:00:00'
Then, you could conceivably construct a template condition that meets your criteria, but as I said, I don’t understand what you are trying to do there.
If the “below 25” condition is met, then by definition the “below 24” and “below 23” conditions are met. I don’t see why you need different conditions for each temperature. > - alias: test
_> trigger: _ > - platform: time > at : ‘23:00:00’ > - platform: time
_> at : ‘23:30:00’ _ > - platform: time
_> at : ‘00:00:00’ _ > condition: > condition: numeric_state > entity_id: sensor.bedroom_temperature > below: 25 > action: > service: homeassistant.turn_off > entity_id: switch.bedroom_fan
The 6:00 one really throws me for a loop though
EDIT:
Upon further review, I now see that you have different temperature requirements at different times.
So the only way to combine these into one automation would be with a complex template criteria.
So you would have the multiple triggers above, and then a template that looks something like this
{{((now().time().strftime("%H")| int == 23 and states.sensor.bedroom_temperature.state <= 23 ) OR (....) OR (.....)}}
So here’s a potential approach.
Have a automation that runs at some time and determines how long the fan should run based upon the temperature.
Store that number as an input_slider value.
Then every 30 minutes run a different automation that turns off the fan if that time has passed.
I will still be running multiple automations which I am trying to avoid - my method works but is not very elegant. I will look into your idea further and see if I can use though.