Is there a template I could use for a date and binary sensor?
Date >= Sept 25th AND binary_sensor.name = off?
Is there a template I could use for a date and binary sensor?
Date >= Sept 25th AND binary_sensor.name = off?
the easiest way I can see is to find the day number of the year that corresponds to your desired date then compare it to the day number of now:
{% set date_val = strptime("2021-09-25", '%Y-%m-%d') %}
{{ (now().strftime('%j') | int > date_val.strftime('%j') | int) and states('binary_sensor.some_name') }}
plug in the date you want into the “date_val” string and the correct binary sensor entity_id.
You could also substitute a date only input_datetime for date_val…I think…I haven’t tested it but I think it should work.
{{ (now().month, now().day) >= (9,25) and is_state('binary_sensor.name', 'off') }}
I didn’t realize you could compare lists like that.
so it compares each element in the first list to its corresponding element in the second list?
Yes. Technically speaking, the parentheses make it a tuple whereas if they were brackets it would be a list.