Automation trigger every 10 mins from 20 to 23

Hi, Id like to start an automation for AC heat in my bedroom between the 20:00 and 23:00 and when the temp is below 18.
Right now Im using time pattern but Im not sure how to make it triggering until 23 then stop

trigger:
  - platform: time_pattern
    hours: "20"
    minutes: /10
  - platform: numeric_state
    entity_id:
      - sensor.bedroom_temperature_1
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 14

AFAIK, time pattern doesn’t support using ranges, so one option would be to add triggers for the other hours

trigger:
  - platform: time_pattern
    hours: "20"
    minutes: /10
  - platform: time_pattern
    hours: "21"
    minutes: /10
  - platform: time_pattern
    hours: "22"
    minutes: /10
  - platform: numeric_state
    entity_id:
      - sensor.bedroom_temperature_1
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 14

Another option would be to make your time pattern less restrictive and use conditions to filter:

trigger:
  - platform: time_pattern
    minutes: /10
  - platform: numeric_state
    entity_id:
      - sensor.bedroom_temperature_1
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 14
condition:
  - condition: template
    value_template: "{{ trigger.platform == 'numeric_state' or now().hour in range(20,23) }}"
trigger:
  - platform: time_pattern
    minutes: /10
  - platform: numeric_state
    entity_id:
      - sensor.bedroom_temperature_1
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 14
condition:
  - condition: time
    after: '19:59:59'
    before: '23:00:01'
  - condition: numeric_state
    entity_id: sensor.bedroom_temperature_1
    below: 14
2 Likes

Wont this solution waste efficienty? THis will trigger the automation every 10 min forever, meanwhile, wasting 6 more row it will be triggered only on those 3 hours?
Or AM I wrong?

ps loving your page :slight_smile:

I guess your first example would fit me. It just trigger at 20, 21,or 22 without annoying the whole system

It’ll trigger every 10 minutes, because that’s what you had. Almost certainly it’s not the best way to do it, but you didn’t share the rest of your automation.

That said the overhead, even on a Pi2, is irrelevant.

Probably you wanted:

trigger:
  - platform: time
    at: '20:00:00'
  - platform: numeric_state
    entity_id:
      - sensor.bedroom_temperature_1
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 14
condition:
  - condition: time
    after: '19:59:59'
    before: '23:00:01'
  - condition: numeric_state
    entity_id: sensor.bedroom_temperature_1
    below: 14

Ive implemented your solution and the automations keep going all the night waking me up 4 times ahahah, jeez. Dont know why but it just kept going at 1, 2, 3, 4, 5 AM until I disabled it.
What could go wrong?

THis is the full automation:

alias: Turn on AC winter
trigger:
  - platform: time_pattern
    hours: "20"
    minutes: /10
  - platform: time_pattern
    hours: "21"
    minutes: /10
  - platform: time_pattern
    hours: "22"
    minutes: /10
  - platform: numeric_state
    entity_id:
      - sensor.bedroom_temperature_1
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 14
condition:
  - condition: time
    weekday:
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
      - sun
    before: input_datetime.spegni_clima
action:
  - service: climate.turn_on
    data: {}
    target:
      entity_id: climate.bedroom_air_conditioning
  - service: climate.set_temperature
    data:
      temperature: 22
      hvac_mode: heat
    target:
      entity_id: climate.bedroom_air_conditioning
  - service: climate.set_fan_mode
    data:
      fan_mode: medium
    target:
      entity_id: climate.bedroom_air_conditioning
mode: single

Ok, then I will use the trigger every 10 mins, also I guess the problem was that I didnt set my range time to be between instead of just before, also I didnt know that it just need one trigger to start the automation