Hi
Could someone please help me with an complex automation (Christmas lights)?
The external sockets should switch on when someone is at home and the Helper ChristmasMode is OFF.
But if the helper is ON and the sun has set and someone is present then the sockets should switch on until mm:hh (helper)
Not Present @ home = SWICH OFF
Present @ home & (Helper ChristmasMode) = OFF, = SWITCH ON
Present @ home & (Helper ChristmasMode) = ON, = SWTICH OFF
Present @ home & (Helper ChristmasMode) = ON, AND SUNSET, = SWITCH ON
What do I have to use as a ls trigger?
How do you prevent that after the set “helpe mm:hh” and or a change to Helper, Zone, Sun doesn’t turn the light on again unintentionally.
alias: Christmaslights
description:
trigger:
- platform: sun
event: sunset
offset: 0
- platform: zone
entity_id: device_tracker.iphone13a
zone: zone.home
event: enter
- platform: zone
entity_id: device_tracker.iphone13b
zone: zone.home
event: enter
- platform: state
entity_id:
- input_boolean.ChristmasMode
to: "on"
from: "off"
condition:
- condition: and
conditions:
- condition: or
conditions:
- condition: zone
entity_id: device_tracker.iphone13a
zone: zone.home
- condition: zone
entity_id: device_tracker.iphone13b
zone: zone.home
- condition: sun
after: sunset
- condition: state
entity_id: input_boolean.ChristmasMode
state: "on"
action:
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.0015dbe332b6a9_2
- switch.0015dbe332b6a9_6
- wait_for_trigger:
- platform: time
at: input_datetime.christmaslights_off_at
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.0015dbe332b6a9_2
- switch.0015dbe332b6a9_6
mode: single
Before I can help you achieve your goal, I need clarification for this requirement:
Currently, your automation’s Zone Trigger only monitors when either device_tracker enters the home zone. If you want to turn off the switch when no one is present, you’ll also need to monitor when the device_tracker leaves the home zone. Did you overlook to include it or did I misunderstand your requirement for when the switch should be turned off?
This community currently has over 150 thousand members. If a day’s delay in responding to you is too slow, the good news is that there are tens of thousands of other users who might have more free time to help you.
Experiment with the following automation and see if it meets your needs. The choose has four conditions and each one corresponds to one of your requirements.
Hi
First. I want to apologize for the stress! I’ve added it now and will see if it works the way it should tonight. I looked at the code, it’s actually quite logical, but I can’t code it myself yet…
How or where should I add a [Time Helper] to the code to switch off the sockets at the set time.
e.g. lights off at 11:00 p.m
In my logic, the first choose overwrites the light and turns it on?! Or am I misunderstanding this?
^*dont wonder I have adjusted the var (I speak German…)
alias: AuĂźensteckdosen (inkl. Weihnachtsmodus)
description: >-
Bei Abwesenheit werden die AuĂźensteckdosen ausgeschalten, bei Anwesenheit
eingeschalten. Wenn Weihnachtsmodus Aktiv, dann schalten die Steckdosen nur
ein wenn jemand Zuhause ist und die Sonne untergegangen ist. Die Steckdosen
schalten sich zur eingestellten Uhrzeit (Helper) aus.
trigger:
- platform: sun
event: sunset
offset: 0
id: an
- platform: numeric_state
entity_id: zone.home
above: 0
id: an
- platform: state
entity_id:
- input_boolean.weihnachtsbeleuchtung
from: "off"
to: "on"
id: an
- platform: numeric_state
entity_id: zone.home
id: aus
below: 1
- platform: time
at: input_datetime.weihnachtsbeleuchtungaus_um
id: aus
- platform: state
entity_id:
- input_boolean.weihnachtsbeleuchtung
from: "on"
to: "off"
id: aus
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: an
- condition: time
before: input_datetime.weihnachtsbeleuchtungaus_um
- condition: state
entity_id: input_boolean.weihnachtsbeleuchtung
state: "on"
- condition: numeric_state
entity_id: zone.home
above: 0
- condition: sun
after: sunset
sequence:
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.0015dbe991b6a9_2
- switch.0015dbe991b6a9_6
- conditions:
- condition: trigger
id: aus
sequence:
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.0015dbe991b6a9_2
- switch.0015dbe991b6a9_6
mode: single
You marked your own post as the Solution yet it’s based on the example I provided you eight days ago. Without that example, you wouldn’t have the basis for fulfilling your original requirements.
In addition, the example you posted appears to have fewer requirements because it no longer takes the device_trackers into account. Anyone reading the requirements you specified in your first post will be led to an alleged solution that doesn’t fulfill all of them.
Anyway, I hope you and your family enjoy the Christmas lighting.