mirror of
https://github.com/CeeWeasel/fresh-home.git
synced 2026-08-09 18:40:14 -04:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -25,10 +25,10 @@ condition:
|
||||
entity_id: media_player.front_room_hub
|
||||
state: "playing"
|
||||
- condition: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.girls_room_clock
|
||||
state: "playing"
|
||||
- condition: state
|
||||
entity_id: media_player.girls_room_hub
|
||||
entity_id: media_player.bedroom_hub
|
||||
state: "playing"
|
||||
- condition: state
|
||||
entity_id: media_player.bathroom_mini
|
||||
|
||||
@@ -7,12 +7,16 @@ trigger:
|
||||
- platform: state
|
||||
entity_id: binary_sensor.bed_presence_c175a4_bed_occupied_either
|
||||
to: "on"
|
||||
# Bed in master bedroom is occupied
|
||||
- platform: state
|
||||
entity_id: input_boolean.master_bed_occupied
|
||||
to: "on"
|
||||
# Radio playing
|
||||
- platform: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
to: "playing"
|
||||
- platform: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
to: "idle"
|
||||
# Light on
|
||||
- platform: state
|
||||
|
||||
@@ -13,6 +13,10 @@ trigger:
|
||||
entity_id: binary_sensor.bed_presence_c175a4_bed_occupied_right
|
||||
to: "off"
|
||||
for: "00:05:00"
|
||||
# Bed in master bedroom is occupied
|
||||
- platform: state
|
||||
entity_id: input_boolean.master_bed_occupied
|
||||
to: "on"
|
||||
- platform: state
|
||||
entity_id:
|
||||
- binary_sensor.master_bedroom_door_contact
|
||||
|
||||
@@ -10,6 +10,10 @@ trigger:
|
||||
- platform: state
|
||||
entity_id: binary_sensor.bed_presence_c175a4_bed_occupied_right
|
||||
to: "on"
|
||||
# Bed in master bedroom is occupied
|
||||
- platform: state
|
||||
entity_id: input_boolean.master_bed_occupied
|
||||
to: "on"
|
||||
|
||||
condition:
|
||||
- condition: state
|
||||
|
||||
@@ -28,7 +28,7 @@ action:
|
||||
- action: media_player.volume_set
|
||||
data:
|
||||
#entity_id: media_player.ma_home_assistant_voice_097b44_media_player
|
||||
entity_id: media_player.ma_master_bedroom_clock
|
||||
entity_id: media_player.ma_bedroom_hub
|
||||
volume_level: 0.90
|
||||
|
||||
- action: input_select.select_option
|
||||
@@ -40,7 +40,7 @@ action:
|
||||
- action: music_assistant.play_media
|
||||
target:
|
||||
#entity_id: media_player.ma_home_assistant_voice_097b44_media_player
|
||||
entity_id: media_player.ma_master_bedroom_clock
|
||||
entity_id: media_player.ma_bedroom_hub
|
||||
data:
|
||||
media_type: playlist
|
||||
#media_id: library://playlist/7
|
||||
|
||||
@@ -8,10 +8,10 @@ trigger:
|
||||
to: "on"
|
||||
# Radio playing
|
||||
- platform: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
to: "playing"
|
||||
- platform: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
to: "idle"
|
||||
# Light on
|
||||
- platform: state
|
||||
|
||||
@@ -29,8 +29,8 @@ action:
|
||||
- media_player.bathroom_mini
|
||||
- media_player.front_room_hub
|
||||
- media_player.kitchen
|
||||
- media_player.girls_room_hub
|
||||
- media_player.master_bedroom_clock
|
||||
- media_player.girls_room_clock
|
||||
- media_player.bedroom_hub
|
||||
volume_level: 0.7
|
||||
- delay: "00:00:03"
|
||||
- action: tts.speak
|
||||
|
||||
@@ -2,7 +2,7 @@ alias: Continue Girls Room Noise
|
||||
id: automation_continue_girls_room_noise
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: media_player.girls_room_hub
|
||||
entity_id: media_player.girls_room_clock
|
||||
from: "playing"
|
||||
condition:
|
||||
- condition: state
|
||||
|
||||
@@ -35,11 +35,11 @@ condition:
|
||||
attribute: source
|
||||
state: "YouTube"
|
||||
- condition: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
attribute: source
|
||||
state: "PBS Kids"
|
||||
- condition: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
attribute: source
|
||||
state: "YouTube"
|
||||
|
||||
@@ -94,23 +94,23 @@ action:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
state: "playing"
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
attribute: source
|
||||
state: "YouTube"
|
||||
- condition: state
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
attribute: source
|
||||
state: "PBS Kids"
|
||||
sequence:
|
||||
- action: media_player.select_source
|
||||
data:
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
source: Home
|
||||
- action: media_player.turn_off
|
||||
data:
|
||||
entity_id: media_player.master_bedroom_clock
|
||||
entity_id: media_player.bedroom_hub
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
alias: "Computer Area Occupied"
|
||||
id: automation_computer_area_occupied
|
||||
mode: restart
|
||||
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id:
|
||||
- binary_sensor.computer_area_occupied
|
||||
to: "on"
|
||||
condition:
|
||||
# Computer area was not already occupied or computer area light is off while not set to manual or off
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: input_boolean.computer_area_occupied
|
||||
state: "off"
|
||||
- condition: and
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: light.computer_area_hue
|
||||
state: "off"
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: input_select.computer_area_mode
|
||||
state: "Off"
|
||||
- condition: state
|
||||
entity_id: input_select.computer_area_mode
|
||||
state: "Manual"
|
||||
|
||||
action:
|
||||
- action: input_boolean.turn_on
|
||||
entity_id: input_boolean.computer_area_occupied
|
||||
@@ -12,7 +12,7 @@ action:
|
||||
target:
|
||||
entity_id: tts.google_translate_en_com
|
||||
data:
|
||||
media_player_entity_id: media_player.front_room_hub, media_player.bathroom_mini, media_player.kitchen, media_player.master_bedroom_clock
|
||||
media_player_entity_id: media_player.front_room_hub, media_player.bathroom_mini, media_player.kitchen, media_player.bedroom_hub
|
||||
message: Attention! A water leak has been detected on the furnace room floor!
|
||||
|
||||
- action: notify.mobile_app_pixel_7
|
||||
|
||||
@@ -31,27 +31,27 @@ action:
|
||||
condition: and
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
state: "playing"
|
||||
|
||||
- action: media_player.volume_set
|
||||
data:
|
||||
volume_level: 0.4
|
||||
target:
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
|
||||
#- action: script.goodnight_kids_youtube_music
|
||||
- action: media_player.shuffle_set
|
||||
data:
|
||||
shuffle: false
|
||||
target:
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
|
||||
- action: media_player.repeat_set
|
||||
data:
|
||||
repeat: all
|
||||
target:
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
|
||||
- action: music_assistant.play_media
|
||||
data:
|
||||
@@ -59,4 +59,4 @@ action:
|
||||
media_type: playlist
|
||||
enqueue: replace
|
||||
target:
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
|
||||
@@ -89,7 +89,7 @@ action:
|
||||
sequence:
|
||||
- action: light.turn_on
|
||||
target:
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
|
||||
- alias: "If the room is set to auto, the lights are on, and the automatic profile is set to Nightlight, change to the Automatic Light Profile scene with a short transition"
|
||||
conditions:
|
||||
@@ -99,7 +99,7 @@ action:
|
||||
state: Auto
|
||||
- alias: "Lights are on"
|
||||
condition: state
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
state: "on"
|
||||
- alias: "Automatic light profile set to Nightlight"
|
||||
condition: state
|
||||
@@ -120,7 +120,7 @@ action:
|
||||
state: Auto
|
||||
- alias: "Lights are on"
|
||||
condition: state
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
state: "on"
|
||||
sequence:
|
||||
- action: scene.turn_on
|
||||
@@ -137,7 +137,7 @@ action:
|
||||
state: Auto
|
||||
- alias: "Lights are off"
|
||||
condition: state
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
state: "off"
|
||||
sequence:
|
||||
- action: scene.turn_on
|
||||
@@ -148,7 +148,7 @@ action:
|
||||
conditions:
|
||||
- alias: "Room not manual or auto and lights are on"
|
||||
condition: state
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
state: "on"
|
||||
- alias: "Room set to Nightlight"
|
||||
condition: state
|
||||
@@ -165,7 +165,7 @@ action:
|
||||
conditions:
|
||||
- alias: "Room not manual or auto and lights are on"
|
||||
condition: state
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
state: "on"
|
||||
sequence:
|
||||
- action: scene.turn_on
|
||||
@@ -178,7 +178,7 @@ action:
|
||||
conditions:
|
||||
- alias: "Room not manual or auto and lights are off"
|
||||
condition: state
|
||||
entity_id: light.girls_room_fan_light_switch_light
|
||||
entity_id: light.girls_room_hue
|
||||
state: "off"
|
||||
sequence:
|
||||
- action: scene.turn_on
|
||||
|
||||
@@ -8,4 +8,4 @@ trigger:
|
||||
|
||||
action:
|
||||
- action: media_player.turn_off
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
|
||||
@@ -7,7 +7,7 @@ trigger:
|
||||
to: "on"
|
||||
|
||||
- platform: state
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
to: "idle"
|
||||
for: 00:00:05
|
||||
|
||||
@@ -22,16 +22,16 @@ action:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
state: "playing"
|
||||
sequence:
|
||||
- action: media_player.media_stop
|
||||
target:
|
||||
entity_id: media_player.ma_girls_room_hub
|
||||
entity_id: media_player.ma_girls_room_clock
|
||||
|
||||
- action: script.search_and_play_playlist
|
||||
data:
|
||||
speaker: media_player.ma_girls_room_hub
|
||||
speaker: media_player.ma_girls_room_clock
|
||||
search_term: Clever Kids Goodnight Songs
|
||||
volume: 0.25
|
||||
repeat: all
|
||||
|
||||
@@ -10,4 +10,4 @@ action:
|
||||
- action: media_player.turn_off
|
||||
data: {}
|
||||
target:
|
||||
entity_id: media_player.ma_home_assistant_voice_097b44_media_player
|
||||
entity_id: media_player.ma_bedroom_hub
|
||||
|
||||
@@ -9,8 +9,8 @@ trigger:
|
||||
action:
|
||||
- action: script.search_and_play_playlist
|
||||
data:
|
||||
speaker: media_player.ma_master_bedroom_clock
|
||||
speaker: media_player.ma_bedroom_hub
|
||||
search_term: CleverThunderstorm
|
||||
volume: 0.25
|
||||
volume: 0.35
|
||||
repeat: all
|
||||
shuffle: false
|
||||
shuffle: false
|
||||
|
||||
@@ -7,7 +7,7 @@ max_exceeded: silent
|
||||
variables:
|
||||
# Map scanner device ID to media player entity ID
|
||||
sources:
|
||||
299e280bcc3579ca9b3ef714677dbf9b: girls_room_hub
|
||||
299e280bcc3579ca9b3ef714677dbf9b: girls_room_clock
|
||||
75060fd1afdd90be: upstairs_speakers
|
||||
# Map tag ID to content
|
||||
tags:
|
||||
|
||||
@@ -8,7 +8,7 @@ max_exceeded: silent
|
||||
variables:
|
||||
# Map scanner device ID to media player entity ID
|
||||
sources:
|
||||
299e280bcc3579ca9b3ef714677dbf9b: girls_room_hub
|
||||
299e280bcc3579ca9b3ef714677dbf9b: girls_room_clock
|
||||
75060fd1afdd90be: front_room_hub
|
||||
# Map tag ID to content
|
||||
tags:
|
||||
|
||||
@@ -7,7 +7,7 @@ max_exceeded: silent
|
||||
variables:
|
||||
# Map scanner device ID to media player entity ID
|
||||
devices:
|
||||
299e280bcc3579ca9b3ef714677dbf9b: media_player.girls_room_hub
|
||||
299e280bcc3579ca9b3ef714677dbf9b: media_player.girls_room_clock
|
||||
|
||||
# Map tag ID to content
|
||||
tags:
|
||||
|
||||
Reference in New Issue
Block a user