Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created July 16, 2020 20:56
Show Gist options
  • Save bessarabov/4a3e141979f2803d89e724982d76eebf to your computer and use it in GitHub Desktop.
Save bessarabov/4a3e141979f2803d89e724982d76eebf to your computer and use it in GitHub Desktop.
automation:
- id: turn_outdoor_lights_on
alias: Turn outdoor lights on
trigger:
- platform: state
entity_id: binary_sensor.somebody_at_dacha
- platform: time_pattern
minutes: "/5"
condition:
- condition: state
entity_id: binary_sensor.somebody_at_dacha
state: 'on'
- condition: template
value_template: '{{ state_attr("sun.sun", "elevation") < 3 }}'
- condition: state
entity_id: switch.sonoff_1000c22252
state: 'off'
action:
- service: switch.turn_on
entity_id: switch.sonoff_1000c22252
- id: turn_outdoor_lights_off_when_nobody
alias: Turn outdoor lights off when nobody
trigger:
- platform: time_pattern
minutes: "/5"
condition:
- condition: state
entity_id: binary_sensor.somebody_at_dacha
state: 'off'
- condition: state
entity_id: switch.sonoff_1000c22252
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.sonoff_1000c22252
- id: turn_outdoor_lights_off_when_bright
alias: Turn outdoor lights off when bright
trigger:
- platform: time_pattern
minutes: "/5"
condition:
- condition: template
value_template: '{{ state_attr("sun.sun", "elevation") > 3 }}'
- condition: state
entity_id: switch.sonoff_1000c22252
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.sonoff_1000c22252
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment