Advertisement
AlexanderGson

Sunset if home

Mar 30th, 2018
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.63 KB | None | 0 0
  1. #This Automation triggers when someone gets home OR when the sun goes below 5 degrees. If someone gets home and the sun is below -10 degrees the lights will start dimmed, otherwise they will start at normal brightness. The time condition prevents the lights from turning on in the middle of the night/morning when the sun rises again and we are home sleeping. And the other two conditions make sure someone has to arrive/be home and the sun has to be below 5 degrees for the action to fire. The action is to start scene A or B depending on sun elevation.
  2.  
  3.   - id: Sunset_if_home
  4.     alias: 'Hemkomst'
  5.     # Triggar scen normalvit eller dimmad_vit beroende på solens position över/under horisonten när någon kommer hem.
  6.     trigger:
  7.       - platform: state
  8.         entity_id: 'group.telefoner'
  9.         to: 'home'
  10.       - platform: numeric_state
  11.         entity_id: sun.sun
  12.         value_template: '{{ states.sun.sun.attributes.elevation }}'
  13.         below: 5
  14.     condition:
  15.       - condition: time
  16.         after: '12:00:00'
  17.         before: '03:00:00'
  18.       - condition: state
  19.         entity_id: group.telefoner
  20.         state: 'home'
  21.       - condition: numeric_state
  22.         entity_id: sun.sun
  23.         value_template: '{{ states.sun.sun.attributes.elevation }}'
  24.         below: 5
  25.     action:
  26.       - service_template: scene.turn_on
  27.         data_template:
  28.           entity_id: >-
  29.             {% set elevation = states.sun.sun.attributes.elevation | int %}
  30.             {% if elevation > -10 and elevation < 5 %}
  31.               scene.normalvit
  32.             {% elif elevation  < -10 %}
  33.               scene.dimmad_vit
  34.             {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement