1
0
Fork 0
ha-config/config/packages/offices.yaml

129 lines
4.1 KiB
YAML

# 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:
entity_id:
- switch.bo_s_office_plug
- switch.bo_s_desk_plug
- id: 2804db52f34458004191f589ed3453dd6f9e1f45
alias: Warm up Bo's office heater
trigger:
- platform: template
value_template: |
{{ is_state('binary_sensor.bo_s_office_door_contact', 'off')
and (is_state('binary_sensor.bo_s_office_motion', 'on')
or is_state('binary_sensor.bo_s_office_is_occupied', 'on'))
and states('sensor.ble_temperature_bos_office_a4c1380f0b98') | float < 19 }}
variables:
service: switch.turn_on
- platform: template
value_template: |
{{ is_state('binary_sensor.bo_s_office_door_contact', 'on')
or (is_state('binary_sensor.bo_s_office_motion', 'off') and is_state('binary_sensor.bo_s_office_is_occupied', 'off'))
or states('sensor.ble_temperature_bos_office_a4c1380f0b98') | float > 20 }}
variables:
service: switch.turn_off
action:
- service: "{{ service }}"
target:
entity_id: switch.bos_office_heater
- 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