Track home occupancy

This commit is contained in:
Correl Roush 2018-06-13 22:41:31 -04:00
parent 2959dcdc19
commit efe0b8849e
2 changed files with 78 additions and 0 deletions

View File

@ -3,6 +3,9 @@ default_view:
icon: mdi:home
entities:
- group.phones
- group.overrides
- binary_sensor.occupied
- binary_sensor.activity
- sun.sun
- weather.dark_sky
@ -77,3 +80,8 @@ phones:
- device_tracker.homeassistant_pixel
- device_tracker.StephaniesIphone
- device_tracker.PhilsGalaxyS7Edge
overrides:
name: Overrides
entities:
- input_boolean.occupied

70
packages/occupancy.yaml Normal file
View File

@ -0,0 +1,70 @@
automation:
- alias: Turn off lights when everyone leaves
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')
}}