91 lines
2.2 KiB
YAML
91 lines
2.2 KiB
YAML
automation:
|
|
- alias: Turn off lights when unoccupied
|
|
action:
|
|
- service: light.turn_off
|
|
data:
|
|
entity_id: group.all_lights
|
|
trigger:
|
|
- platform: state
|
|
entity_id: binary_sensor.occupied
|
|
to: 'off'
|
|
- alias: Set occupied
|
|
action:
|
|
- service: input_boolean.turn_on
|
|
data:
|
|
entity_id: input_boolean.occupied
|
|
trigger:
|
|
- platform: state
|
|
entity_id: binary_sensor.activity
|
|
to: 'on'
|
|
condition:
|
|
- condition: state
|
|
entity_id: group.phones
|
|
state: 'not_home'
|
|
- alias: Unset occupied
|
|
action:
|
|
- service: input_boolean.turn_off
|
|
data:
|
|
entity_id: input_boolean.occupied
|
|
trigger:
|
|
- platform: state
|
|
entity_id: binary_sensor.activity
|
|
to: 'off'
|
|
for:
|
|
minutes: 10
|
|
- platform: state
|
|
entity_id: group.phones
|
|
to: 'not_home'
|
|
for:
|
|
minutes: 10
|
|
condition:
|
|
- condition: state
|
|
entity_id: group.phones
|
|
state: 'not_home'
|
|
- condition: state
|
|
entity_id: binary_sensor.activity
|
|
state: 'off'
|
|
|
|
|
|
input_boolean:
|
|
occupied:
|
|
name: House is occupied
|
|
icon: mdi:home
|
|
|
|
binary_sensor:
|
|
- platform: template
|
|
sensors:
|
|
occupied:
|
|
friendly_name: Somebody is home
|
|
device_class: occupancy
|
|
value_template: >-
|
|
{{ is_state('group.phones', 'home')
|
|
or is_state('input_boolean.occupied', 'on')
|
|
}}
|
|
activity:
|
|
friendly_name: House in use
|
|
device_class: occupancy
|
|
value_template: >-
|
|
{{ is_state('group.all_lights', 'on')
|
|
or is_state('media_player.den', 'playing')
|
|
}}
|
|
|
|
group:
|
|
Occupancy:
|
|
view: yes
|
|
icon: mdi:account-group
|
|
entities:
|
|
- binary_sensor.occupied
|
|
- binary_sensor.activity
|
|
- group.phones
|
|
- group.occupancy_automations
|
|
- group.occupancy_overrides
|
|
occupancy_automations:
|
|
name: Automations
|
|
entities:
|
|
- automation.turn_off_lights_when_unoccupied
|
|
- automation.set_occupied
|
|
- automation.unset_occupied
|
|
occupancy_overrides:
|
|
name: Overrides
|
|
entities:
|
|
- input_boolean.occupied
|