From 6b8d14999380c131dc4e28a588d7f31311f9ab88 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Fri, 17 Jan 2020 22:38:03 +0100 Subject: [PATCH] Auto-off feature --- config_creation/ir_automations.py | 28 ++++++++++++-- scenes.yaml | 21 +++++++++++ scripts.yaml | 63 +++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) diff --git a/config_creation/ir_automations.py b/config_creation/ir_automations.py index dd922b9..b71550f 100644 --- a/config_creation/ir_automations.py +++ b/config_creation/ir_automations.py @@ -36,10 +36,30 @@ def get_config(): 'key_yellow': '[scene] schlafzimmer_ganz_hell', 'key_blue': '[scene] schlafzimmer_blau', - 'key_tv': '[timed_light_off] 30', - 'key_video': '[timed_light_off] 15', - 'key_music': '[timed_light_off] 10', - 'key_pictures': '[timed_light_off] 5', + 'key_tv': [service('script.turn_on', 'script.timed_sleep', + variables={'media_content_id': 'spotify:playlist:37i9dQZF1DXbcPC6Vvqudd', # Regen + 'light_off_secs': 15 * 60, + 'music_off_secs': 45 * 60, + 'shuffle': 1, + })], + 'key_video': [service('script.turn_on', 'script.timed_sleep', + variables={'media_content_id': 'Good Night', + 'light_off_secs': 15 * 60, + 'music_off_secs': 45 * 60, + 'shuffle': 0, + })], + 'key_music': [service('script.turn_on', 'script.timed_sleep', + variables={'media_content_id': 'spotify:playlist:37i9dQZF1DXbcPC6Vvqudd', # Regen + 'light_off_secs': 5 * 60, + 'music_off_secs': 20 * 60, + 'shuffle': 1, + })], + 'key_pictures': [service('script.turn_on', 'script.timed_sleep', + variables={'media_content_id': 'Good Night', + 'light_off_secs': 5 * 60, + 'music_off_secs': 20 * 60, + 'shuffle': 0, + })], 'key_power': [ # Music & Lights off service('media_player.media_pause', 'media_player.bedroompi'), diff --git a/scenes.yaml b/scenes.yaml index 3524820..3351688 100644 --- a/scenes.yaml +++ b/scenes.yaml @@ -492,6 +492,27 @@ state: 'off' light.schlafzimmer_schrank: state: 'off' +- name: Schlafzimmer Einschlaflicht + id: schlafzimmer_einschlaflicht + entities: + light.schlafzimmer_deckenlampe: + state: false + light.schlafzimmer_schrank: + state: false + light.bett_martin: + state: true + brightness: 70 + xy_color: + - 0.502 + - 0.414 + light.bett_rebecca: + state: true + brightness: 70 + xy_color: + - 0.502 + - 0.414 + light.schlafzimmer_fluter: + state: false - name: Schlafzimmer Orange id: schlafzimmer_orange entities: diff --git a/scripts.yaml b/scripts.yaml index e69de29..8a367ba 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -0,0 +1,63 @@ +#timed_sleep_rain: +# alias: "Einschlafen mit Regen" +# sequence: +# - service: media_player.play_media +# data: +# entity_id: media_player.bedroompi +# media_content_id: spotify:playlist:37i9dQZF1DXbcPC6Vvqudd +# media_content_type: music +# - service: scene.turn_on +# data: +# entity_id: scene.schlafzimmer_einschlaflicht +# - service: squeezebox_telnet.squeezebox_call_method +# data: +# command: sleep +# parameters: +# - 2700 +# - service: light.turn_off +# data: +# transition: 900 +# entity_id: group.bedroom +# +# +#timed_sleep_music: +# alias: "Einschlafen mit Musik" +# sequence: +# - service: media_player.play_media +# data: +# entity_id: media_player.bedroompi +# media_content_id: "Good Night" +# media_content_type: music +# - service: scene.turn_on +# data: +# entity_id: scene.schlafzimmer_einschlaflicht +# - service: light.turn_off +# data: +# transition: 900 +# entity_id: group.bedroom + +timed_sleep: + alias: "Einschlafen mit Licht und Musik auto-aus" + sequence: + - service: media_player.shuffle_set + data_template: + entity_id: "media_player.bedroompi" + shuffle: > + {% if shuffle %}True{% else %}False{% endif %} + - service: media_player.play_media + data_template: + entity_id: "media_player.bedroompi" + media_content_id: "{{media_content_id}}" + media_content_type: "music" + - service: scene.turn_on + data: + entity_id: scene.schlafzimmer_einschlaflicht + - service: light.turn_off + data_template: + transition: "{{light_off_secs}}" + entity_id: group.bedroom + - service: media_player.squeezebox_call_method + data_template: + entity_id: "media_player.bedroompi" + command: "sleep {{music_off_secs}}" +