Set input_boolean to on if sensor attribute goes below value between two set times?

I’ve tried this for a while now, if the temp goes below 2C between 9pm and 6am I want the input_boolean to be set to on.

The way it works now is that if it’s above 2C at 9pm and then goes below 2C before 6am it work’s as it should. But if it’s already cold outside it doesn’t see the “below 2C” change.

- id: '1581627412807'
  alias: Car Heater if I'm home mon-fri. (Below 2C 21:00-06:00)
  description: ''
  trigger:
  - at: 05:30
    platform: time
  condition:
  - condition: state
    entity_id: person.per_kristian
    state: home
  - condition: state
    entity_id: input_boolean.below_2c
    state: 'on'
  action:
  - entity_id: switch.osramsmartplugbasement
    service: switch.turn_on
  - delay: 02:00:00
  - entity_id: switch.osramsmartplugbasement
    service: switch.turn_off
- id: '1581627833924'
  alias: Turn on input.boolean if outside temperature goes below 2C 21:00-06:00
  description: ''
  trigger:
  - platform: template
    value_template: '{{(states.sensor.outside_temperature.state | int) <= (2 | int)}}'
  condition:
  - after: '21:00:00'
    before: 05:59:59
    condition: time
  action:
  - entity_id: input_boolean.below_2c
    service: input_boolean.turn_on

Add a 2nd trigger: at 21:00 and a second condition of temp below 2C. Triggers default to or so your automation will run either when temp drops below 2C or when the time is 9pm.

Edit: you probably have to set your time trigger to 21:00:01 so your after: 21:00:00 condition is true.

Could just wait for it to happen.

- id: '1581627833924'
  alias: Turn on input.boolean if outside temperature goes below 2C 21:00-06:00
  description: ''
  trigger:
  - platform: time
    at: "21:00:00"
  action:
  # Waits for the temperature to drop below 2. Once this evaluates to true, it will continue.
  - wait_template: "{{ (states.sensor.outside_temperature.state | int) <= 2 }}"
    # Wait until 6am
    timeout: '09:00:00'
    # By default, it will continue even on timeout. Don't want that...
    continue_on_timeout: false
  - service: input_boolean.turn_on
    entity_id: input_boolean.below_2c

Also, that alias is unwieldy. I would put all of that in the description. You will currently have an automation called "automation.turn_on_input.boolean_if_outside_temperature_goes_below_2c_21:00_06:00" or however it translates periods and dashes. Give it a better name!