Awnings date range did not seem to work please help

well this month my awnings should work but they did not please anyone that knows can see any errors in my automation ? the automation works between specific days of may and september 2 hours before sunset when there is no rain :

alias: Project "Cooldown  phase 2"
  description: ''
  trigger:
  - event: sunset
    offset: -02:00:00
    platform: sun
  condition:
  - condition: not
    conditions:
    - condition: state
      entity_id: sensor.dark_sky_icon
      state: rain
  - condition: template
    value_template: '{% set fromts = ''05-09'' %} {% set tots = ''03-20'' %} {{ fromts
      <= now()|as_timestamp|timestamp_custom(''%m-%d'', False) <= tots }}'
  action:
  - data:
      entity_id: switch.sonoff_100016270b_3
    entity_id: switch.sonoff_100016270b_2
    service: switch.turn_on
  - delay: 00:02:00
  - data:
      entity_id: switch.sonoff_100016270b_2
    entity_id: switch.sonoff_100016270b_3
    service: switch.turn_on
  - delay: 00:02:00
  - data:
      entity_id: switch.sonoff_100016270b_2
    entity_id: switch.sonoff_100016270b_3
    service: switch.turn_off
  mode: single

You have too many single quotes, try this:

{% set fromts = '05-09' %} {% set tots = '03-20' %} {{ fromts
      <= now()|as_timestamp|timestamp_custom('%m-%d', False) <= tots }}

unfortunately this is not it cause other automations i have with the same range setup works perfect

Try this version of the condition:

  condition:
    - "{{ states('sensor.dark_sky_icon') != 'rain' }}"
    - "{{ (5,3) <= (now().month, now().day) <= (9,20) }}"

This uses shorthand notation Template Conditions.

The first template checks if the dark_sky_icon is not rain.
The second template checks if the current month and date are between May 5 and September 20.

Are you sure that the condition is the problem? Have you tried triggering the automation manually? To me the action part looks a bit weird underneath data you list two different entity_ids with a different indentation.

{% set fromts = ''05-09'' %} {% set tots = ''03-20'' %}

is from 9 May to 20 March, a backwards range which I think always evaluates as false. As per @123’s post above, I suspect you meant 09-20.

I also agree with @T1ppes that the action looks odd.

jesus guys you saved me again , troon you were right i just fixed the range condition to what taras gave me and it worked taras you rock i just runned the action and it did work

1 Like

but ill once need your help what if for example want to open a light every 23 of may every year?

I assume you want to turn it on at a specific time on May 23rd. There are several ways to do it. Here’s one example (turns it on at 08:25):

trigger:
  - platform: template
    value_template: '{{ (now().month, now().day) == (5,23) and (now().hour, now().minute) == (8,25) }}'
1 Like