First greetings to all and thanks for the huge amount of hints and help.
But still, it does not help me
Home Assistant runs as a docker installation on a Synology Diskstation, I did update recently. Most devices are Zigbee2mqtt which is not relevant for the problem.
My goal is to switch on my Christmas decoration in the morning. The start time shall be different for the weekend. The action simply turns on an input_boolean switch. That triggers the real switching. I found this idea in this forum. I summed up everything in a package file from where I copy parts and add english comment as the names and descriptions are in German. I do not change the code.
For completeness, this is the switch which should be toggled by the automation (innen is german for inside, lichter is lights):
input_boolean:
# Switch to toggle group of light
xmas_lichter_innen:
name: "Weihnachtsbeleuchtung im Haus"
# initial: off
I can also use it to manually turn on/off the lights.
These are the input-fields for giving different starttimes (germen startzeit)
input_datetime:
# time when switch should turn on during the week
xmas_innen_startzeit_morgens:
name: "Weihnachtsbeleuchtung Zeit zum Einschalten morgens innen"
has_date: false
has_time: true
initial: '06:30'
# time when switch should turn on at weekends
xmas_innen_startzeit_morgens_we:
name: "Weihnachtsbeleuchtung Wochenend-Zeit zum Einschalten morgens innen"
has_date: false
has_time: true
initial: '08:00'
That was the easy part, now for the automation.
The trigger should fire at both the start-time I entered in the input_datetime fields for weekdays and weekends. The condition should decide:
- is the time equal to weekdays start-time and do we have a weekday?
or - is the time equal to weekends start-time and do we have weekend?
If one of both is true, the input_boolean should be turned on.
automation:
- id: xmas_innen_morgens_ein
description: Weihnachtsbeleuchtung innen morgens ein zu fester Zeit
alias: Weihnachtsbeleuchtung innen morgens ein
trigger:
- platform: time
at: input_datetime.xmas_innen_startzeit_morgens
- platform: time
at: input_datetime.xmas_innen_startzeit_morgens_we
condition:
- condition: or
conditions:
- condition: template
value_template: >-
{{ states.sensor.time.state == states.input_datetime.xmas_innen_startzeit_morgens.state[0:5]
and now().weekday() < 5
}}
- condition: template
value_template: >-
{{ states.sensor.time.state == states.input_datetime.xmas_innen_startzeit_morgens_we.state[0:5]
and now().weekday() > 4
}}
action:
- service: input_boolean.turn_on
entity_id: input_boolean.xmas_lichter_innen
mode: single
And this does not fire, I never found an entry in the logbook or the logfile (homeassistant.components.automation: debug).
Yes, I checked the YAML with YAML Validator and I read conditions manual. I pasted the template and parts of the template into the developer tools and watched the parts of the template to show the expected values (I love that automatic update). I also tried now().strftime instead of sensor.time and other stuff.
I have the same automation for outside lights and for both to turn them off in the evening. As an experienced programmer I am able to keep my errors consistent, so none of them four works
Can anyone give me a hint what I am doing wrong?
Any relevant information missing?
I am fighting nearly two weeks now and I hope to get my lights working until christmas. At least the turn on for sunset with a delay depending on the weather