Files
Home-Assistant-Configs/packages/master_bedroom.yaml

120 lines
3.6 KiB
YAML

# This file is here because I didn't want to crowd up my own YAML file...
input_boolean:
master_bedroom_sleeping:
name: Master Bedroom Sleeping
icon: mdi:sleep
automation:
- id: 09c3d481-11df-459c-9240-d002b9b2ef53
alias: 'Master Bedroom Handling'
description: "For scheduled operations in the Master Bedroom"
initial_state: true
mode: single
trigger:
- platform: time
at: input_datetime.master_bedroom_wakeup
id: wakeup
condition:
- condition: state
entity_id: group.adults
state: home
action:
- choose:
- conditions:
- condition: trigger
id: wakeup
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.master_bedroom_sleeping
# Currently, input_boolean.master_bedroom_sleeping is turned on by the Goodnight flow in Node-RED whenever I go to bed.
# That is why there is only one trigger here at the moment.
- id: 7889ccf2-1fee-4819-8e59-5ad4e5879b0a
alias: 'Master Bedroom Sleeping'
description: 'Handles the response to the Master Bedroom Sleeping toggle'
initial_state: true
mode: restart
trigger:
- platform: state
entity_id: input_boolean.master_bedroom_sleeping
from: 'off'
to: 'on'
id: sleep-on
- platform: state
entity_id: input_boolean.master_bedroom_sleeping
from: 'on'
to: 'off'
id: sleep-off
action:
- choose:
- conditions:
- condition: trigger
id: sleep-off
sequence:
- service: script.master_bedroom_wakeup
- conditions:
- condition: trigger
id: sleep-on
sequence:
- service: script.master_bedroom_sleep
script:
master_bedroom_wakeup:
alias: 'Master Bedroom Wakeup'
mode: restart
sequence:
- service: switch.turn_off
target:
entity_id: switch.master_bedroom_echo_dot_do_not_disturb_switch
- service: media_player.volume_set
target:
entity_id: media_player.master_bedroom_echo_dot
data:
volume_level: >
{% if is_state('input_boolean.give_me_darkness','on') %}
{{ states('input_number.master_bedroom_echo_dot_night_volume') }}
{% else %}
{{ states('input_number.master_bedroom_echo_dot_day_volume') }}
{% endif %}
- if:
- condition: template
value_template: >
{% set weather = states('weather.iron_nerd_weather_station') %}
{% if weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] %}
true
{% elif (states('sensor.pirateweather_cloud_coverage') | int) > 50 %}
true
{% else %}
false
{% endif %}
then:
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_scenes
data:
option: Adaptive
- service: script.volume_reset
master_bedroom_sleep:
alias: 'Master Bedroom Sleep'
mode: restart
sequence:
- wait_template: "{{ is_state('light.master_bedroom_lights','off') }}"
timeout:
minutes: 1
continue_on_timeout: true
- service: switch.turn_on
target:
entity_id: switch.adaptive_lighting_master_bedroom
- service: switch.turn_off
target:
entity_id: switch.adaptive_lighting_sleep_mode_master_bedroom
- service: input_text.set_value
target:
entity_id: input_text.master_bedroom_selected_scene
data:
value: Adaptive
# TODO: Figure out which actions to move here, and which ones to keep in Node-RED