Any idea why this does not trigger?
- id: 'awaylights'
alias: Away Lights
trigger:
- entity_id: group.family
from: home
platform: state
to: not_home
for:
hours: 24
condition:
- condition: sun
after: sunset
after_offset: "+01:00:00"
action:
- service: light.turn_on
entity_id: light.keittio
- delay: "00:{{ (range(30, 120)|random|int) }}:00"
- service: light.turn_off
entity_id: light.keittio
- service: light.turn_on
entity_id: light.hue_color_lamp_1
data:
brightness: 200
kelvin: 2700
- delay: "00:{{ (range(15, 90)|random|int) }}:00"
- service: light.turn_off
entity_id: light.hue_color_lamp_1
aheath
(Andrew)
July 22, 2019, 9:51pm
2
for:
hours: 24
This means that your family needs to be away from the house for entire 24 hours before the automation will trigger. Is that what you are after? Try removing those lines, and the automation should trigger as soon as group.family
is marked away.
yes, that is the purpose. I don’t want it to trigger until 24h has passed as sometimes somebody is home with mobile off and then it would trigger these lights.
aheath
(Andrew)
July 22, 2019, 10:02pm
4
Ok. The automation will only trigger once, after 24 hours of everyone being away. If that happens to be before sunset, then your automation will will fail the condition and won’t run.
You may be better off using the sunset + offset as your trigger, and using the status of the group as the condition. That way it will fire every night at sunset if it passes the condition.
Ah, OK that makes sense. I will try that. Thank you!!
OK, I modified the script and it still does not trigger. Any ideas what I might have done wrong?
- id: 'awaylights'
alias: Away Lights
trigger:
platform: sun
event: sunset
offset: "+01:45:00"
condition:
- condition: state
entity_id: group.family
state: not_home
for:
hours: 12
action:
- service: light.turn_on
entity_id: light.keittio_katto_1
- delay: "00:{{ (range(30, 120)|random|int) }}:00"
- service: light.turn_off
entity_id: light.keittio
- service: light.turn_on
entity_id: light.hue_color_lamp_1
data:
brightness: 200
kelvin: 2700
- delay: "00:{{ (range(15, 90)|random|int) }}:00"
- service: light.turn_off
entity_id: light.hue_color_lamp_1
Anyone? I really cannot figure this out.
jjhtpc
(Justin Wurth)
July 24, 2019, 9:25pm
8
You need to have both items in the trigger (if this or this occur) and both items in the condition and set the condition as an and condition.
Hello, Now it seems to work This is the latest code:
- id: 'awaylights'
alias: Away Lights
trigger:
- platform: sun
event: sunset
offset: "+01:45:00"
- platform: state
entity_id: group.family
from: home
to: not_home
for:
hours: 24
condition:
condition: and
conditions:
- condition: state
entity_id: group.family
state: 'not_home'
for:
hours: 24
- condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
- service: light.turn_on
entity_id: light.keittio_katto_1
- delay: "00:{{ (range(30, 120)|random|int) }}:00"
- service: light.turn_off
entity_id: light.keittio
- service: light.turn_on
entity_id: light.hue_color_lamp_1
data:
brightness: 200
kelvin: 2700
- delay: "00:{{ (range(15, 90)|random|int) }}:00"
- service: light.turn_off
entity_id: light.hue_color_lamp_1