How to trigger at 5pm or 8pm an action only in 5 winter months

Hi, i’d like to call a script which is executed either on 5pm or 8pm local time during Nov-March every year. Based on a temperature sensor it should close a window. I can make it happen in general, see script below, works well, but need to understand both an “or” condition (to have either times) as well as a month condition (script only run Nov-March). Thx for any suggestion!

What i did so far:

alias: close_at_5pm
description: ""
trigger:
  - platform: time
    at: "75:00:00"
condition:
  - condition: numeric_state
    entity_id: sensor.temperature_swis_punkt
    below: 15
action:
  - service: script.windowclose
    data: {}
mode: single

What time is this?

There are only 24 hours in a day.

See this post for a few hints:

Could you share a few more information on when you actually want the close-windows script to be started?

For the simple november to march condition you could use something like this:

- condition: template
  value_template: '{{ now().month >= 11 or now().month <= 3 }}'

… But I have the suspicion that you rather might like to have something based on the actual season or sun-down which can be accomplished with these sensors:

1 Like

Hi, the thinking behind is that in the “cold season” a window which was forgotten to be closed, will be closed by the script, whereas at warm seasons it might be good to keep the window open because then the room can cool down.

For the moment that thinking is based on cold months. I am not sure whether other parameters might be helpful (e.g. the max temp that day was above 24 Celsius or so) … not wanting to add more complexity to it for now.

How would “and” or “or” triggers be set?

Triggers are always OR logic. If you want them to be AND logic you have to include them as conditions as well.

1 Like

And if you wnat to put OR into the condition block there is a special OR condition:

1 Like
alias: close_at_5_and_8pm
description: ""
trigger:
  - platform: time
    at:
      - "17:00:00"
      - "20:00:00"
condition:
  - "{{ now().month in [1, 2, 3, 11, 12] }}"
  - condition: numeric_state
    entity_id: sensor.temperature_swis_punkt
    below: 15
action:
  - service: script.windowclose
    data: {}
mode: single
1 Like

You legend! I wasnt aware that Season was a built in sensor that could just be added! This has allowed me to do exactly what i want which is to only perform a task if not during “Winter”. :smiley:

Thanks @elfrinjo