kamyrdol32
(kamyrdol32)
September 22, 2019, 3:21pm
1
Hello, i neew help with automations. I created automation to automatic turn on light + open curtains when i’m back to home.
- alias: Leaver Cover Close
trigger:
platform: state
entity_id: person.kamil
from: "not_home"
to: "home"
action:
- service: cover.open_cover
entity_id: cover.living_room_cover
- service: cover.open_cover
entity_id: cover.kitchen_cover
- service: homeassistant.turn_on
entity_id: light.decoration_wall_light_left
- service: homeassistant.turn_on
entity_id: light.decoration_wall_light_right
I want to make the lights change to ON only when sun is below horizon, can i do that? This:
- service: homeassistant.turn_on
entity_id: light.decoration_wall_light_left
- service: homeassistant.turn_on
entity_id: light.decoration_wall_light_right
houtknots
(Jayce)
September 22, 2019, 3:35pm
2
You can use light.turn_on
as the service,
- service: light.turn_on
entity_id: light.decoration_wall_light_left, light.decoration_wall_light_right
For the Automation on sunset you can use the trigger:
- event: sunset
platform: sun
kamyrdol32
(kamyrdol32)
September 22, 2019, 8:38pm
3
I want to turn on lights only if is night. Trigger is coming to home
tom_l
September 22, 2019, 10:51pm
4
Add a condition:
- alias: Leaver Cover Close
trigger:
platform: state
entity_id: person.kamil
from: "not_home"
to: "home"
condition:
condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: cover.open_cover
entity_id: cover.living_room_cover
- service: cover.open_cover
entity_id: cover.kitchen_cover
- service: homeassistant.turn_on
entity_id: light.decoration_wall_light_left
- service: homeassistant.turn_on
entity_id: light.decoration_wall_light_right
Alternatively you can add this sensor:
- platform: template
sensor:
sun_elevation:
value_template: '{{ states.sun.sun.attributes.elevation }}'
friendly_name: "Sun Elevation"
And add the numeric condition below: 0
hiscorebob
(Hiscorebob)
September 23, 2019, 7:37am
5
If you use a condition for sunset, all the actions (incl open covers) will only run after sunset. I’d suggest creating a 2nd automation for the lights only, and only use the sunset condition there.
tom_l
September 23, 2019, 7:53am
6
Or (if that is indeed the wanted action) just move the condition to the actions.
- alias: Leaver Cover Close
trigger:
platform: state
entity_id: person.kamil
from: "not_home"
to: "home"
action:
- service: cover.open_cover
entity_id: cover.living_room_cover
- service: cover.open_cover
entity_id: cover.kitchen_cover
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
- service: light.turn_on
entity_id: light.decoration_wall_light_left
- service: light.turn_on
entity_id: light.decoration_wall_light_right
1 Like