2022-05-11 16:41:13 +10:00
|
|
|
homeassistant:
|
|
|
|
customize_glob:
|
|
|
|
"input_boolean.*_in_bed":
|
|
|
|
templates: # custom-ui
|
|
|
|
icon: >
|
|
|
|
if (state === 'on')
|
|
|
|
return 'mdi:bed';
|
|
|
|
return 'mdi:bed-empty';
|
|
|
|
|
2022-08-24 13:50:56 +10:00
|
|
|
magic_areas:
|
|
|
|
|
2022-05-11 16:41:13 +10:00
|
|
|
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:
|
2022-08-24 13:50:56 +10:00
|
|
|
- id: 29b7b074ebcbfa873522
|
|
|
|
alias: turn off lights when everyone is in bed
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
2022-08-31 10:25:05 +10:00
|
|
|
entity_id: group.everyone_in_bed
|
2022-08-24 13:50:56 +10:00
|
|
|
from: "off"
|
|
|
|
to: "on"
|
|
|
|
for:
|
|
|
|
minutes: 1
|
|
|
|
action:
|
|
|
|
- service: light.turn_off
|
|
|
|
target:
|
2023-04-25 07:36:58 +10:00
|
|
|
area_id:
|
|
|
|
- ri_s_office
|
|
|
|
- bo_s_office
|
|
|
|
- living_room
|
|
|
|
- kitchen
|
|
|
|
- hallway
|
|
|
|
- laundry_room
|
|
|
|
- bathroom
|
|
|
|
- analog_room
|
|
|
|
- outdoors
|
|
|
|
- garden_shed
|
2022-08-24 13:50:56 +10:00
|
|
|
- service: light.turn_on
|
|
|
|
data:
|
|
|
|
color_temp: 462
|
|
|
|
brightness_pct: 10
|
|
|
|
target:
|
|
|
|
entity_id: light.sconce
|
|
|
|
|
2022-05-11 16:41:13 +10:00
|
|
|
- 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:
|
2022-05-27 09:27:40 +10:00
|
|
|
toggle: input_boolean.ri_in_bed
|
2022-05-11 16:41:13 +10:00
|
|
|
for:
|
|
|
|
minutes: 1
|
|
|
|
- platform: state
|
|
|
|
entity_id:
|
|
|
|
- sensor.ri_s_phone
|
|
|
|
variables:
|
2022-05-27 09:27:40 +10:00
|
|
|
toggle: input_boolean.bo_in_bed
|
2022-05-11 16:41:13 +10:00
|
|
|
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:
|
2022-05-27 10:28:04 +10:00
|
|
|
# - "{{ target_state == 'off' }}"
|
2022-05-11 16:41:13 +10:00
|
|
|
- alias: "plausible sleep time"
|
|
|
|
condition: time
|
|
|
|
after: "21:00:00"
|
2022-05-27 09:27:40 +10:00
|
|
|
before: "08:30:00"
|
2022-05-11 16:41:13 +10: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 }}"
|
|
|
|
|
2023-04-25 07:36:58 +10:00
|
|
|
- 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
|
|
|
|
|
2022-05-11 16:41:13 +10:00
|
|
|
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
|
2022-05-19 16:27:09 +10:00
|
|
|
- switch.bos_office_heater
|
2022-05-11 16:41:13 +10:00
|
|
|
- switch.ri_s_desk_plug
|
2022-08-24 13:50:56 +10:00
|
|
|
|
2023-04-25 07:36:58 +10:00
|
|
|
- cover.analog_room_blinds
|
|
|
|
- cover.bos_office_blinds
|
|
|
|
- cover.bedroom_blinds
|
|
|
|
- cover.front_gate
|
|
|
|
- climate.living_room_a_c
|
2023-05-24 16:25:38 +10:00
|
|
|
- switch.living_room_a_c_jet_mode
|
2023-04-25 07:36:58 +10:00
|
|
|
- light.fairy_lights
|
|
|
|
|
2022-05-11 16:41:13 +10:00
|
|
|
include_entity_globs:
|
|
|
|
- binary_sensor.*_is_occupied
|
2022-05-19 16:27:09 +10:00
|
|
|
- binary_sensor.*_motion
|
|
|
|
- binary_sensor.*_presence
|
|
|
|
- binary_sensor.*_occupancy
|
2022-05-11 16:41:13 +10:00
|
|
|
- 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*"
|
2022-08-24 13:50:56 +10:00
|
|
|
- light.shelly_*
|
2022-05-11 16:41:13 +10:00
|
|
|
- sensor.*garden*
|
|
|
|
- sensor.*battery_temperature*
|
|
|
|
- sensor.*forecast*
|
|
|
|
- sensor.*weather*
|
|
|
|
- sensor.nas_*
|
|
|
|
- sensor.*_nas_*
|
2023-04-25 07:36:58 +10:00
|
|
|
|
|
|
|
# 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
|
2022-05-11 16:41:13 +10:00
|
|
|
exclude_domains: []
|
|
|
|
entity_config:
|
|
|
|
vacuum.robot_vacuum:
|
|
|
|
linked_battery_sensor: sensor.robot_vacuum_battery_level
|
|
|
|
linked_battery_charging_sensor: binary_sensor.robot_vacuum_charging
|
2022-08-24 13:50:56 +10:00
|
|
|
|
|
|
|
- name: shelly
|
|
|
|
port: 21225
|
|
|
|
filter:
|
|
|
|
include_entity_globs:
|
|
|
|
- light.shelly_*
|