I need help from you again.
I have created an automation with which I execute a script by switch.
But this script should be executed automatically at certain times on certain days of the week.
Unfortunately I can not do this.
The script should be executed on the days Sunday to Thursday each 23:00.
And Saturday and Sunday 01:00 o’clock
should be executed.
Create a template sensor in configuration.yaml (or template include file)
template:
- name: "execute"
unique_id: "execute"
state: >-
{% set hr = now().hour %}
{% set day = now().weekday() %}
{% if (day in [0,1,2,3,6] and hr == 23) or (day in [5,6] and hr == 13) %}
on
{% else %}
off
{% endif %}
add this as a condition if the time and date must be met or
condition:
- condition: state
entity_id: sensor.execute
state: 'on'
you can also set this a a trigger
trigger:
- platform: state
entity_id: sensor.execute
from: 'off'
to: 'on'
Here it is setup in developer tools with the hr set to 14 to make it trigger on
Either one will work. If you use input_datetime’s they are held to the minute and work just fine. OP is asking for executing at multiple times on specific days. You could add all to the triggers for each of the specifications but the template sensor accomplishes it with a cleaner automation.