I want to run some automation when all persons left our home. At the moment I am a little confused because I found conflicting information (old vs. new guides) online. Maybe someone may enlighten me.
I’ve used the GUI for this and the going away part (“Niemand zu hause = nobody at home”) works fine…I think. At least it triggers.
alias: Niemand zu Hause
description: ""
trigger:
- platform: state
entity_id:
- person.xx
- person.yy
to: not_home
condition:
- condition: state
entity_id: person.xx
state: not_home
- condition: state
entity_id: person.yy
state: not_home
action:
...
mode: single
But the code for coming home (“Jemand kommt nach Hause”) does not trigger / start. Any ideas for that?
alias: Jemand kommt nach Hause
description: ""
trigger:
- platform: state
entity_id:
- person.xx
- person.yy
to: home
for:
hours: 0
minutes: 0
seconds: 0
from: not_home
condition:
- condition: state
entity_id: person.xx
state: not_home
- condition: state
entity_id: person.yy
state: not_home
action:
...
mode: single
Additionally I want to ad conditions (i.e. sunrise/sunset) for single actions (turning lights on should only be done when the sun is down) for single actions.
I assume I have to use this code, but do not know how or were to paste it or if it is even possible to add it to actions.
Thank you for the quick response.
The zone.home was exactly what I was looking for…I just did not understand that it is a numerical value and not a state: they do not work (I’ve just copy-pasted your code).
Go to Developer tools > States and search for zone.home. What do you see in the column State?
Try to share the full automation code here (please remove any private info) so it will be easier to help. Not rarely this is just some blank space missing somewhere…
I feel not good enough to debug.
But maybe my automation helps?
It switches on a light when I’m at home or come home and the sun is below horizon for 30 minutes.
alias: Außenlicht bei Sonnenuntergang
description: >-
Lichterkette auf der Terrasse 30 min nach Sonnenuntergang einschalten und um
23:30 Uhr ausschalten
trigger:
- platform: sun
event: sunset
offset: "00:30:00"
id: sun
- platform: state
entity_id: device_tracker.iphone
from: not_home
to: home
id: home
- platform: time
at: "23:30"
id: time
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: sun
sequence:
- condition: state
entity_id: device_tracker.iphone
state: home
- service: switch.turn_on
target:
device_id: <id>
data: {}
- conditions:
- condition: trigger
id: home
sequence:
- condition: sun
after: sunset
after_offset: "00:30:00"
- condition: time
before: "23:30"
- service: switch.turn_on
target:
device_id: <id>
data: {}
- conditions:
- condition: trigger
id: time
sequence:
- service: switch.turn_off
target:
device_id: <id>
data: {}
default: []
mode: single
Is there a way to do this ONLY when coming home from out of the house? Say if my phone never left for three days, I don’t want it to activate, but if I leave for 15 minutes and come back, it should activate?