From a7580b851ad4f53d2baa486a5d146c2d8a8ac917 Mon Sep 17 00:00:00 2001 From: Claus Dethlefsen Date: Sat, 25 Apr 2026 13:16:03 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=B8rklokke:=20gendan=20volumen=20p=C3=A5=20?= =?UTF-8?q?lille=20bad=20efter=20afspilning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/automations/doerklokke_bag2.yaml | 159 ++--------------- include/automations/doerklokke_for.yaml | 213 +++-------------------- include/scripts/doorbell.yaml | 54 +----- include/scripts/spil_paa_lille_bad.yaml | 31 ++++ 4 files changed, 81 insertions(+), 376 deletions(-) create mode 100644 include/scripts/spil_paa_lille_bad.yaml diff --git a/include/automations/doerklokke_bag2.yaml b/include/automations/doerklokke_bag2.yaml index 814f6b7..87614c1 100644 --- a/include/automations/doerklokke_bag2.yaml +++ b/include/automations/doerklokke_bag2.yaml @@ -55,53 +55,12 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/german-shephard.mp3 - media_content_type: audio/mpeg - metadata: - title: german-shephard.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/german-shephard.mp3 - media_content_type: audio/mpeg - metadata: - title: german-shephard.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + - service: script.spil_paa_lille_bad + data: + lydfil: german-shephard.mp3 + volumen: "{{ lille_bad_volumen }}" - sequence: - service: media_player.volume_set data: @@ -165,53 +124,12 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/dog-barking-2-bullmastiff.mp3 - media_content_type: audio/mpeg - metadata: - title: dog-barking-2-bullmastiff.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/dog-barking-2-bullmastiff.mp3 - media_content_type: audio/mpeg - metadata: - title: dog-barking-2-bullmastiff.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + - service: script.spil_paa_lille_bad + data: + lydfil: dog-barking-2-bullmastiff.mp3 + volumen: "{{ lille_bad_volumen }}" - sequence: - service: tts.speak target: @@ -233,53 +151,12 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/two-tone-chime.mp3 - media_content_type: audio/mpeg - metadata: - title: two-tone-chime.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/two-tone-chime.mp3 - media_content_type: audio/mpeg - metadata: - title: two-tone-chime.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + - service: script.spil_paa_lille_bad + data: + lydfil: two-tone-chime.mp3 + volumen: "{{ lille_bad_volumen }}" - sequence: - service: tts.speak target: diff --git a/include/automations/doerklokke_for.yaml b/include/automations/doerklokke_for.yaml index bddde46..fe46704 100644 --- a/include/automations/doerklokke_for.yaml +++ b/include/automations/doerklokke_for.yaml @@ -44,53 +44,13 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/Halloween-doorbell.mp3 - media_content_type: audio/mpeg - metadata: - title: Halloween-doorbell.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/doorbell.mp3 - media_content_type: audio/mpeg - metadata: - title: doorbell.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + lille_bad_lydfil: "{{ 'Halloween-doorbell.mp3' if (now().hour >= 20 or now().hour < 6) else 'doorbell.mp3' }}" + - service: script.spil_paa_lille_bad + data: + lydfil: "{{ lille_bad_lydfil }}" + volumen: "{{ lille_bad_volumen }}" - sequence: - service: tts.speak target: @@ -127,53 +87,12 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/german-shephard.mp3 - media_content_type: audio/mpeg - metadata: - title: german-shephard.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/german-shephard.mp3 - media_content_type: audio/mpeg - metadata: - title: german-shephard.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + - service: script.spil_paa_lille_bad + data: + lydfil: german-shephard.mp3 + volumen: "{{ lille_bad_volumen }}" - sequence: - service: tts.speak target: @@ -195,53 +114,12 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/dog-barking-2-bullmastiff.mp3 - media_content_type: audio/mpeg - metadata: - title: dog-barking-2-bullmastiff.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/dog-barking-2-bullmastiff.mp3 - media_content_type: audio/mpeg - metadata: - title: dog-barking-2-bullmastiff.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + - service: script.spil_paa_lille_bad + data: + lydfil: dog-barking-2-bullmastiff.mp3 + volumen: "{{ lille_bad_volumen }}" - sequence: - service: tts.speak target: @@ -263,53 +141,12 @@ sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: 0.5 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/two-tone-chime.mp3 - media_content_type: audio/mpeg - metadata: - title: two-tone-chime.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: 0.8 - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/two-tone-chime.mp3 - media_content_type: audio/mpeg - metadata: - title: two-tone-chime.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ 0.5 if (now().hour >= 20 or now().hour < 6) else 0.8 }}" + - service: script.spil_paa_lille_bad + data: + lydfil: two-tone-chime.mp3 + volumen: "{{ lille_bad_volumen }}" - sequence: - service: tts.speak target: diff --git a/include/scripts/doorbell.yaml b/include/scripts/doorbell.yaml index aca6bb3..4d88fc1 100644 --- a/include/scripts/doorbell.yaml +++ b/include/scripts/doorbell.yaml @@ -10,53 +10,13 @@ doorbell: sequence: - parallel: - sequence: - - choose: - - conditions: - - condition: time - after: '20:00:00' - before: '06:00:00' - sequence: - - service: media_player.volume_set - data: - volume_level: "{{ volumennat }}" - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/doorbell-shortened-100308.mp3 - media_content_type: audio/mpeg - metadata: - title: doorbell-shortened-100308.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source - default: - - service: media_player.volume_set - data: - volume_level: "{{ volumendag }}" - target: - entity_id: media_player.lille_badevaerelse - - service: media_player.play_media - target: - entity_id: media_player.lille_badevaerelse - data: - media_content_id: media-source://media_source/local/doorbell.mp3 - media_content_type: audio/mpeg - metadata: - title: doorbell.mp3 - thumbnail: - media_class: music - children_media_class: - navigateIds: - - {} - - media_content_type: app - media_content_id: media-source://media_source + - variables: + lille_bad_volumen: "{{ volumennat if (now().hour >= 20 or now().hour < 6) else volumendag }}" + lille_bad_lydfil: "{{ 'doorbell-shortened-100308.mp3' if (now().hour >= 20 or now().hour < 6) else 'doorbell.mp3' }}" + - service: script.spil_paa_lille_bad + data: + lydfil: "{{ lille_bad_lydfil }}" + volumen: "{{ lille_bad_volumen }}" - sequence: - service: media_player.volume_set data: diff --git a/include/scripts/spil_paa_lille_bad.yaml b/include/scripts/spil_paa_lille_bad.yaml new file mode 100644 index 0000000..456f114 --- /dev/null +++ b/include/scripts/spil_paa_lille_bad.yaml @@ -0,0 +1,31 @@ +spil_paa_lille_bad: + alias: "Spil lyd på lille bad og gendan volumen bagefter" + fields: + lydfil: + description: Filnavn (fx doorbell.mp3) + example: doorbell.mp3 + volumen: + description: Volumen der spilles ved (0.0-1.0) + example: 0.8 + sequence: + - variables: + gammel_volumen: "{{ state_attr('media_player.lille_badevaerelse', 'volume_level') | default(0.3) }}" + - service: media_player.volume_set + data: + volume_level: "{{ volumen }}" + target: + entity_id: media_player.lille_badevaerelse + - service: media_player.play_media + target: + entity_id: media_player.lille_badevaerelse + data: + media_content_id: "media-source://media_source/local/{{ lydfil }}" + media_content_type: audio/mpeg + - delay: "00:00:02" + - wait_template: "{{ states('media_player.lille_badevaerelse') not in ['playing'] }}" + timeout: "00:01:30" + - service: media_player.volume_set + data: + volume_level: "{{ gammel_volumen }}" + target: + entity_id: media_player.lille_badevaerelse