# If door opens when sun is down, turn lights on # If sun sets and door is open or presense detected, turn lights on # If lights on but no presence for one hour, turn lights off # When lights turned off, turn off desk and couch plugs # When lights turned on, turn on desk and couch plugs # When bo leaves home, turn off desk plug # When everybody leaves home, turn off couch plug automation: - id: a1459b6c502b7d9df65a101dd31c9c55f164388c alias: Turn on Bo's office when door opened or motion detected trigger: - platform: state entity_id: - binary_sensor.bo_s_office_door_contact - binary_sensor.bo_s_office_motion from: "off" to: "on" action: # - if: # - "{{ is_state('sun.sun', 'below_horizon') }}" # then: - service: light.turn_on data: transition: 0.25 kelvin: 3000 brightness_pct: 100 target: area_id: bo_s_office - service: switch.turn_on target: area_id: bo_s_office - id: 8a32a559bfcf43ddfd6ec03a8071eecfbf8161bb alias: Turn off Bo's office if no motion for a while trigger: - platform: state entity_id: binary_sensor.bo_s_office_motion from: "on" to: "off" for: minutes: 15 condition: "{{ is_state('binary_sensor.bo_s_office_is_occupied', 'off') }}" action: - service: light.turn_off target: area_id: - bo_s_office - if: - "{{ is_state('binary_sensor.bo_s_office_door_contact', 'off') }}" # closed then: - if: - or: - "{{ is_state('sensor.bandersnatch_displays', '1') }}" - not: "{{ is_state('device_tracker.bandersnatch_hass', 'home') }}" then: - service: switch.turn_off target: entity_id: switch.bo_s_desk_plug - service: switch.turn_off target: entity_id: switch.bo_s_office_plug - id: 2d1034acdee3afde7b67224b4898bd87b5cd356c alias: Turn on Ri's office when door opened trigger: - platform: state entity_id: binary_sensor.ri_s_office_door_contact from: "off" to: "on" action: - if: - "{{ is_state('sun.sun', 'below_horizon') }}" then: - service: light.turn_on data: transition: 0.25 kelvin: 3000 brightness_pct: 100 target: area_id: ri_s_office - service: switch.turn_on target: area_id: ri_s_office - id: b3f8aa9d20fee297accbd6aad27ba29c28aa02dc alias: Turn off offices when in bed trigger: - platform: state entity_id: group.everyone_in_bed to: "on" for: minutes: 5 action: - service: light.turn_off target: area_id: - bo_s_office - ri_s_office - service: switch.turn_off target: area_id: - bo_s_office - ri_s_office