421 lines
14 KiB
YAML
421 lines
14 KiB
YAML
# This file is for entities/automations that are specific to Emmalynn
|
|
|
|
input_boolean:
|
|
emma_sleeping:
|
|
name: Emma Sleeping
|
|
icon: mdi:sleep
|
|
emma_has_napped:
|
|
name: Emma Has Napped
|
|
icon: mdi:check
|
|
|
|
input_datetime:
|
|
emma_bedtime:
|
|
name: Emma Bedtime
|
|
has_date: false
|
|
has_time: true
|
|
icon: mdi:fan-auto
|
|
emma_wakeup:
|
|
name: Emma Wakeup
|
|
has_date: false
|
|
has_time: true
|
|
icon: mdi:fan-off
|
|
emma_down_for_nap:
|
|
name: Emma Down For Nap
|
|
has_date: true
|
|
has_time: true
|
|
icon: mdi:sleep
|
|
emma_up_from_nap:
|
|
name: Emma Up From Nap
|
|
has_date: true
|
|
has_time: true
|
|
icon: mdi:eye
|
|
|
|
sensor:
|
|
- platform: template
|
|
sensors:
|
|
emma_nap_info:
|
|
friendly_name: Emma Nap Info
|
|
unique_id: 60664690-0eb6-400a-83d5-21e56f029910
|
|
value_template: >
|
|
{% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %}
|
|
{% set wakeup = state_attr('input_datetime.emma_up_from_nap','timestamp') | int %}
|
|
{% set diff = (wakeup - asleep) | int %}
|
|
{% set hour = diff | timestamp_custom('%H', false) | int %}
|
|
{% set minute = diff | timestamp_custom('%M', false) | int %}
|
|
{% set day = now().strftime("%-d") %}
|
|
{% set asleep_day = asleep | timestamp_custom("%-d") %}
|
|
{% set wakeup_day = wakeup | timestamp_custom("%-d") %}
|
|
{% if is_state('input_boolean.emma_has_napped','on') or ((asleep_day == day) and (wakeup_day == day)) %}
|
|
Emma napped today for {{ hour }} hours and {{ minute }} minutes.
|
|
{% elif is_state('input_boolean.emma_has_napped','off') and ((asleep_day == day) and (wakeup_day != day)) %}
|
|
Emma appears to be napping currently.
|
|
{% else %}
|
|
Emma does not appear to have napped yet today.
|
|
{% endif %}
|
|
icon_template: mdi:sleep
|
|
|
|
automation:
|
|
- id: 4f01dff7-be22-4850-a05e-1906e3151441
|
|
alias: 'Emma Sleeping'
|
|
description: "Handles the response to the Emma Sleeping toggle"
|
|
mode: restart
|
|
trigger:
|
|
- platform: state
|
|
entity_id: input_boolean.emma_sleeping
|
|
from: 'off'
|
|
to: 'on'
|
|
id: sleep-on
|
|
- platform: state
|
|
entity_id: input_boolean.emma_sleeping
|
|
from: 'on'
|
|
to: 'off'
|
|
id: sleep-off
|
|
condition:
|
|
- condition: state
|
|
entity_id: group.adults
|
|
state: 'home'
|
|
action:
|
|
- choose:
|
|
- conditions:
|
|
- condition: trigger
|
|
id: sleep-on
|
|
sequence:
|
|
- if:
|
|
- condition: and
|
|
conditions:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_has_napped
|
|
state: 'off'
|
|
- condition: time
|
|
before: "23:00:00"
|
|
after: "04:00:00"
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.emma_down_for_nap
|
|
data:
|
|
datetime: "{{ as_timestamp(now()) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}"
|
|
- service: script.emma_sleep
|
|
- conditions:
|
|
- condition: trigger
|
|
id: sleep-off
|
|
sequence:
|
|
- if:
|
|
- condition: and
|
|
conditions:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_has_napped
|
|
state: 'off'
|
|
- condition: time
|
|
before: "23:30:00"
|
|
after: "15:00:00"
|
|
then:
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.emma_up_from_nap
|
|
data:
|
|
datetime: "{{ as_timestamp(now()) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}"
|
|
- delay:
|
|
milliseconds: 500
|
|
- if:
|
|
- condition: template
|
|
value_template: >
|
|
{% from 'time.jinja' import ct %}
|
|
{% set ct = ct() | int %}
|
|
{% set proposed = ct + 10800 %}
|
|
{{ proposed < 82800 }}
|
|
then:
|
|
- service: script.emma_bedroom_scheduling_evening
|
|
else:
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.emma_bedtime
|
|
data:
|
|
time: "{{ (state_attr('input_datetime.emma_up_from_nap','timestamp') + 10800) | timestamp_custom('%H:%M') }}"
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.emma_has_napped
|
|
- service: script.emma_wakeup
|
|
|
|
- id: '1655415573165'
|
|
alias: Emma Bedroom Handling
|
|
description: "For scheduled operations in Emma's bedroom"
|
|
mode: restart
|
|
trigger:
|
|
- platform: time
|
|
at: input_datetime.emma_wakeup
|
|
id: emma-wakeup
|
|
- platform: time
|
|
at: input_datetime.emma_bedtime
|
|
id: emma-bedtime
|
|
condition:
|
|
- condition: state
|
|
entity_id: input_boolean.vacation_mode
|
|
state: 'off'
|
|
action:
|
|
- choose:
|
|
- conditions:
|
|
- condition: trigger
|
|
id: emma-wakeup
|
|
sequence:
|
|
- service: input_boolean.turn_off
|
|
target:
|
|
entity_id: input_boolean.emma_sleeping
|
|
- conditions:
|
|
- condition: trigger
|
|
id: emma-bedtime
|
|
sequence:
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.emma_sleeping
|
|
|
|
- id: e44c2ab8-00cd-40ab-9b42-824511ac20aa
|
|
alias: Emma Naptime Climate
|
|
description: Sets the climate mode for when Emma goes down for nap
|
|
mode: restart
|
|
trigger:
|
|
- platform: state
|
|
entity_id: sensor.pirateweather_temperature
|
|
- platform: state
|
|
entity_id: input_number.emma_naptime_aircon_threshold
|
|
- platform: state
|
|
entity_id: input_boolean.hot_day
|
|
condition:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_sleeping
|
|
state: 'off'
|
|
- condition: state
|
|
entity_id: input_boolean.emma_bedroom_climate_override
|
|
state: 'off'
|
|
action:
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id: input_select.naptime_climate_mode_emma_aircon
|
|
data:
|
|
option: >
|
|
{% set temp = states('sensor.pirateweather_temperature') | int %}
|
|
{% set threshold = states('input_number.emma_naptime_aircon_threshold') | int %}
|
|
{% if (temp >= threshold) or is_state('input_boolean.hot_day','on') %}
|
|
AC
|
|
{% else %}
|
|
White Noise
|
|
{% endif %}
|
|
|
|
script:
|
|
emma_sleep:
|
|
alias: 'Emma Sleep'
|
|
icon: mdi:lightbulb-night
|
|
mode: restart
|
|
sequence:
|
|
- if:
|
|
- condition: time
|
|
after: '04:00:00'
|
|
before: '16:00:00'
|
|
then:
|
|
- service: script.emma_bedroom_scheduling_evening
|
|
# Lighting
|
|
- choose:
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: binary_sensor.early_night_mode
|
|
state: 'on'
|
|
sequence:
|
|
- service: light.turn_on
|
|
target:
|
|
entity_id:
|
|
- light.emma_bedroom_light
|
|
- light.hallway_overhead
|
|
- delay:
|
|
seconds: 1
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id:
|
|
- input_select.emma_bedroom_scenes
|
|
- input_select.upstairs_hallway_scenes
|
|
data:
|
|
option: Adaptive
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: binary_sensor.early_night_mode
|
|
state: 'off'
|
|
sequence:
|
|
- service: light.turn_on
|
|
target:
|
|
entity_id: light.emma_bedroom_light
|
|
# Climate
|
|
- choose:
|
|
- conditions:
|
|
- condition: or
|
|
conditions:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_has_napped
|
|
state: 'on'
|
|
- condition: time
|
|
after: "23:00:00"
|
|
before: "04:00:00"
|
|
sequence:
|
|
- choose:
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: input_select.scheduled_climate_mode_emma_aircon
|
|
state: AC
|
|
sequence:
|
|
- service: fan.turn_on
|
|
target:
|
|
entity_id: fan.emma_air_conditioner
|
|
- service: script.text_notify
|
|
data:
|
|
who: "parents"
|
|
title: "Emma Climate Schedule"
|
|
message: "The air conditioner in Emma's Bedroom has been activated."
|
|
type: normal
|
|
tag: emma-climate
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: input_select.scheduled_climate_mode_emma_aircon
|
|
state: White Noise
|
|
sequence:
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.white_noise_emma_bedroom
|
|
- service: script.text_notify
|
|
data:
|
|
who: "parents"
|
|
title: "Emma Climate Schedule"
|
|
message: "White noise has been activated in Emma's Bedroom."
|
|
type: normal
|
|
tag: emma-climate
|
|
default:
|
|
- service: script.text_notify
|
|
data:
|
|
who: "parents"
|
|
title: "Emma Climate Schedule"
|
|
message: "No option selected for Emma's climate mode. No devices will be activated."
|
|
type: normal
|
|
tag: emma-climate
|
|
- conditions:
|
|
- condition: and
|
|
conditions:
|
|
- condition: state
|
|
entity_id: input_boolean.emma_has_napped
|
|
state: 'off'
|
|
- condition: time
|
|
before: "23:00:00"
|
|
after: "04:00:00"
|
|
sequence:
|
|
- choose:
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: input_select.naptime_climate_mode_emma_aircon
|
|
state: AC
|
|
sequence:
|
|
- service: fan.turn_on
|
|
target:
|
|
entity_id: fan.emma_air_conditioner
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: input_select.naptime_climate_mode_emma_aircon
|
|
state: White Noise
|
|
sequence:
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.white_noise_emma_bedroom
|
|
|
|
emma_wakeup:
|
|
alias: 'Emma Wakeup'
|
|
icon: mdi:weather-sunset-up
|
|
mode: restart
|
|
sequence:
|
|
# Lighting
|
|
- variables:
|
|
brightness: "{{ state_attr('switch.adaptive_lighting_emma_bedroom','brightness_pct') }}"
|
|
- choose:
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: binary_sensor.early_night_mode
|
|
state: 'on'
|
|
sequence:
|
|
- service: switch.turn_off
|
|
target:
|
|
entity_id: switch.adaptive_lighting_emma_bedroom
|
|
- delay:
|
|
seconds: 1
|
|
- service: light.turn_on
|
|
target:
|
|
entity_id: light.emma_bedroom_light
|
|
data:
|
|
brightness_pct: "{{ brightness }}"
|
|
transition: >
|
|
{% from 'time.jinja' import timer_duration %}
|
|
{{ timer_duration('input_number.wakeup_lights_fade_night') }}
|
|
- service: light.turn_on
|
|
target:
|
|
entity_id: light.hallway_overhead
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id:
|
|
- input_select.upstairs_hallway_scenes
|
|
- input_select.master_bedroom_scenes
|
|
data:
|
|
option: Adaptive
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: binary_sensor.early_night_mode
|
|
state: 'off'
|
|
sequence:
|
|
- service: switch.turn_off
|
|
target:
|
|
entity_id: switch.adaptive_lighting_emma_bedroom
|
|
- delay:
|
|
seconds: 1
|
|
- service: light.turn_on
|
|
target:
|
|
entity_id: light.emma_bedroom_light
|
|
data:
|
|
brightness_pct: "{{ brightness }}"
|
|
transition: >
|
|
{% from 'time.jinja' import timer_duration %}
|
|
{{ timer_duration('input_number.wakeup_lights_fade_day') }}
|
|
# Climate/White Noise
|
|
- if:
|
|
- condition: state
|
|
entity_id: binary_sensor.early_night_mode
|
|
state: 'off'
|
|
then:
|
|
- delay:
|
|
minutes: 5
|
|
else:
|
|
- delay:
|
|
minutes: "{{ states('input_boolean.wakeup_lights_fade_night') }}"
|
|
- service: input_boolean.turn_off
|
|
target:
|
|
entity_id: input_boolean.white_noise_emma_bedroom
|
|
- if:
|
|
- condition: template
|
|
value_template: >-
|
|
{{ is_state('fan.emma_air_conditioner','on') and is_state('input_boolean.hot_day','off') }}
|
|
then:
|
|
- service: script.turn_on
|
|
target:
|
|
entity_id: script.emma_aircon_shutoff
|
|
- service: input_select.select_option
|
|
target:
|
|
entity_id: input_select.emma_bedroom_scenes
|
|
data:
|
|
option: Adaptive
|
|
|
|
emma_aircon_shutoff:
|
|
alias: 'Emma Air Conditioner Shutoff'
|
|
mode: restart
|
|
description: 'Attempt to shut off air conditioner after compressor stops running'
|
|
sequence:
|
|
- wait_template: "{{ is_state('binary_sensor.emma_aircon_compressor','off') }}"
|
|
timeout:
|
|
minutes: 15
|
|
continue_on_timeout: true
|
|
- delay:
|
|
seconds: 5
|
|
- service: fan.turn_off
|
|
target:
|
|
entity_id: fan.emma_air_conditioner
|