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

290 lines
8.0 KiB
YAML

homeassistant:
customize_glob:
"input_boolean.*_in_bed":
templates: # custom-ui
icon: >
if (state === 'on')
return 'mdi:bed';
return 'mdi:bed-empty';
magic_areas:
proximity:
bo_home:
zone: home
unit_of_measurement: m
devices:
- person.bo_jeanes
ri_home:
zone: home
unit_of_measurement: m
devices:
- person.ri_liu
group:
family:
name: Family
entities:
- person.bo_jeanes
- person.ri_liu
anyone_in_bed:
name: Anyone in bed
entities:
- input_boolean.bo_in_bed
- input_boolean.ri_in_bed
everyone_in_bed:
name: Everyone in bed
all: true
entities:
- input_boolean.bo_in_bed
- input_boolean.ri_in_bed
automation:
- id: 29b7b074ebcbfa873522
alias: turn off lights when everyone is in bed
trigger:
- platform: state
entity_id: group.everyone_in_bed
from: "off"
to: "on"
for:
minutes: 1
action:
- service: light.turn_off
target:
area_id:
- ri_s_office
- bo_s_office
- living_room
- kitchen
- hallway
- laundry_room
- bathroom
- analog_room
- outdoors
- garden_shed
- service: light.turn_on
data:
color_temp: 462
brightness_pct: 10
target:
entity_id: light.sconce
- id: not_in_bed
alias: No longer in bed when phone leaves room
trigger:
- platform: state
entity_id:
- sensor.ri_s_phone
from: "bedroom"
variables:
toggle: input_boolean.ri_in_bed
for:
minutes: 1
- platform: state
entity_id:
- sensor.ri_s_phone
variables:
toggle: input_boolean.bo_in_bed
from: "bedroom"
for:
minutes: 1
condition:
- "{{ trigger.to_state.state not in ['not_home', 'unknown', 'unavailable'] }}"
- "{{ is_state(toggle, 'on') }}"
action:
- service: input_boolean.turn_off
target:
entity_id: "{{ toggle }}"
- id: in_bed
alias: In bed detection (based on phone charging)
trigger:
- platform: state
entity_id: sensor.ris_iphone_hass_battery_state
variables:
# battery_state can be: Full, Charging, Not Charging.
target_state: '{% if is_state("sensor.ris_iphone_hass_battery_state", "Not Charging") %}off{% else %}on{% endif %}'
toggle: input_boolean.ri_in_bed
person: person.ri_liu
- platform: state
entity_id: sensor.bos_iphone_hass_battery_state
variables:
target_state: '{% if is_state("sensor.bos_iphone_hass_battery_state", "Not Charging") %}off{% else %}on{% endif %}'
toggle: input_boolean.bo_in_bed
person: person.bo_jeanes
condition:
- or:
# - "{{ target_state == 'off' }}"
- alias: "plausible sleep time"
condition: time
after: "21:00:00"
before: "08:30:00"
- "{{ trigger.to_state.state not in ['unknown', 'unavailable'] }}"
- "{{ not is_state(toggle, target_state) }}"
- "{{ is_state(person, 'home') }}"
action:
- service: "input_boolean.turn_{{ target_state }}"
data:
entity_id: "{{ toggle }}"
- id: bedroom_blinds
alias: Manage bedroom blinds
trigger:
- platform: state
entity_id: binary_sensor.in_bed
to: "on"
id: in_bed
for:
hours: 2 # proxy for "is asleep"
- id: sunset
platform: state
entity_id: sun.sun
to: below_horizon
action:
- service: cover.close_cover
target:
area_id: bedroom
# if we've gone to bed, wait for the us to get up or 8 hours to pass (whichever happens first) to then re-open
# blinds.
- choose:
- conditions:
condition: trigger
id: in_bed
sequence:
- wait_for_trigger:
- platform: template
value_template: >
{{ is_state('binary_sensor.in_bed', 'off') }}
for:
minutes: 10 # _staying_ out of bed
timeout:
hours: 6 # 2 hours already part of trigger condition, for 8 hours total
- wait_for_trigger:
- platform: template
value_template: >
{{ is_state('sun.sun', 'above_horizon') and now().hour >= 7 }}
- service: cover.set_cover_position
data:
position: 20
target:
area_id: bedroom
- wait_for_trigger:
- platform: template
value_template: >
{{ is_state('binary_sensor.anyone_in_bed', 'off') }}
timeout:
hours: 2
- service: cover.open_cover
target:
area_id: bedroom
template:
- binary_sensor:
- unique_id: in_bed
name: In bed
state: |
{{ is_state('input_boolean.bo_in_bed', 'on') or is_state('input_boolean.ri_in_bed', 'on') }}
icon: |
{% if is_state("binary_sensor.in_bed", "on") %}
mdi:bed
{% else %}
mdi:bed-empty
{% endif %}
device_class: occupancy
- unique_id: sleeping
name: Sleeping
state: |
{{ is_state('input_boolean.bo_in_bed', 'on') and is_state('input_boolean.ri_in_bed', 'on') }}
icon: |
{% if is_state("binary_sensor.sleeping", "on") %}
mdi:bed
{% else %}
mdi:bed-empty
{% endif %}
lifx:
light:
- broadcast: !secret iot_broadcast
homekit:
- name: house
port: 21223
filter:
include_entities:
- vacuum.robot_vacuum
- fan.bedroom_purifier
- sensor.bedroom_purifier_humidity
- sensor.bedroom_purifier_pm2_5
- sensor.bedroom_purifier_temperature
- input_boolean.bo_in_bed
- input_boolean.ri_in_bed
# - binary_sensor.in_bed
- switch.bo_s_desk_plug
- switch.bo_s_office_plug
- switch.bos_office_heater
- switch.ri_s_desk_plug
- cover.analog_room_blinds
- cover.bos_office_blinds
- cover.bedroom_blinds
- cover.front_gate
- climate.living_room_a_c
- switch.living_room_a_c_jet_mode
- light.fairy_lights
include_entity_globs:
- binary_sensor.*_is_occupied
- binary_sensor.*_motion
- binary_sensor.*_presence
- binary_sensor.*_occupancy
- sensor.ble_temperature*
- sensor.ble_humidity*
- sensor.ble_illuminance*
include_domains:
- light
exclude_entities: []
exclude_entity_globs:
- "*.*tent*"
- "sensor.*fridge*"
- "sensor.*freezer*"
- "sensor.*cure*"
- "sensor.*stash*"
- light.shelly_*
- sensor.*garden*
- sensor.*battery_temperature*
- sensor.*forecast*
- sensor.*weather*
- sensor.nas_*
- sensor.*_nas_*
# Magic areas entities
- light.area_*
- light.sleep_lights_*
- light.global_lights
- light.interior_lights
- light.exterior_lights
- light.overhead_lights*
- light.accent_lights*
- cover.area_*
- switch.area_light_control_*
- binary_sensor.area_battery_*
- binary_sensor.area_connectivity_*
- binary_sensor.area_door_*
- binary_sensor.area_tamper_*
- binary_sensor.area_update_*
- binary_sensor.area_global
exclude_domains: []
entity_config:
vacuum.robot_vacuum:
linked_battery_sensor: sensor.robot_vacuum_battery_level
linked_battery_charging_sensor: binary_sensor.robot_vacuum_charging
- name: shelly
port: 21225
filter:
include_entity_globs:
- light.shelly_*