Nesting switch automations

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.

I currently have a yaml for each time/temperature setting so I am looking for a way to combine all of them into 1 single yaml.

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 (.....)}}

I only want the fan on for a certain amount of time depending on how hot my bedroom is. If it is above 24C then the fan stays on all night.

Below 22 then it is on for 30 minutes
Below 23 then 1 hour
Below 24 then 1.5 hours

Does that make sense ?

yes, see my edit above

Yes this was as simple as I could make it then thought I could nest them into 1 yaml for each temperature - maybe more complex that I envisioned :cry:

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.

Thanks.