cyberphox
(Gene Mills)
January 13, 2019, 4:25pm
1
Finally diving into automations after using HA for the past year.
I’ve seen lots of examples of people using automated lights on when arriving home using Motion detection but for the life of me I’ve searched and searched and can’t find anyone using something similar for Presence detection.
I’ve successfully got my garage lights coming on when arriving home but I just can’t figure out the rest of the code to have them turn off automatically after x number of minutes
What I have so far in automations.yaml
alias: 'Arriving Home '
trigger:
platform: state
entity_id: device_tracker.iphonexr
from: 'not_home'
to: 'home'
action:
service: light.turn_on
entity_id: light.garage_outdoor_light_8
What am I missing? I tried delay with adding another service for light.turn.off but got an error about duplicate mapping key.
finity
January 13, 2019, 5:20pm
2
Assuming you always want that to happen after the light gets turned on with this automation then this should work:
- alias: 'Arriving Home '
trigger:
platform: state
entity_id: device_tracker.iphonexr
from: 'not_home'
to: 'home'
action:
- service: light.turn_on
entity_id: light.garage_outdoor_light_8
- delay: '00:10:00'
- service: light.turn_off
entity_id: light.garage_outdoor_light_8
1 Like
cyberphox
(Gene Mills)
January 13, 2019, 8:39pm
3
Thanks so much! I was racking my brain around that for 3 days now!!!
Raffi
(Raffaele)
January 24, 2020, 10:30am
4
Is it possible to configure such a away?
automation:
trigger:
platform: sun
event: sunset
alias: 'Arriving Home ’
trigger:
platform: state
entity_id: device_tracker.iphonexr
from: ‘not_home’
to: ‘home’
action:
service: light.turn_on
entity_id: light.garage_outdoor_light_8
delay: ‘00:10:00’
service: light.turn_off
entity_id: light.garage_outdoor_light_8
finity
January 26, 2020, 7:16am
5
we can’t answer that because you didn’t format your code to display properly.
Raffi
(Raffaele)
January 26, 2020, 9:11am
6
condition:
condition: sun
after: sunset
- alias: 'Arriving Home '
trigger:
platform: state
entity_id: device_tracker.iphonetaffa
from: 'not_home'
to: 'home'
action:
- service: light.turn_on
entity_id: light.garage_outdoor_light_8
- delay: '00:4:00'
- service: light.turn_off
entity_id: light.garage_outdoor_light_8
Hope this is better, excuse me I’m newbie
- alias: arriving home
trigger:
platform: state
entity_id: device_tracker.iphonetaffa
to: home
condition:
condition: sun
after: sunset
action:
- service: light.turn_on
entity_id: light.garage_outdoor_light_8
- delay: '00:4:00'
- service: light.turn_off
entity_id: light.garage_outdoor_light_8
try this…
Raffi
(Raffaele)
January 27, 2020, 6:10pm
8
No, sorry, it does not lit the light. I checked well entities but nothing
Raffi
(Raffaele)
January 29, 2020, 7:00pm
9
Hi tried usuccessful the following:
- alias: TEST
trigger:
platform: state
entity_id: device_tracker.iphone_raffaele_6s
from: 'not_home'
to: 'home'
condition:
condition: sun
after: sunset
action:
- service: light.turn_on
entity_id: switch.shelly_shsw_25_c4ce78_1
- delay: 00:04:00
- service: light.turn_off
entity_id: switch.shelly_shsw_25_c4ce78_1
Salty
(John)
January 29, 2020, 7:07pm
10
You are trying to control switches not lights.
Change the service lines to switch.turn_on and switch.turn_off instead of light.turn…
Raffi
(Raffaele)
January 29, 2020, 9:34pm
11
You right. Thank you very much