Last active
May 7, 2024 14:15
-
-
Save CodeOptimist/8a31d6146adf84400626570e3b15367f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias: "Music: Keep-alive" | |
description: "" | |
trigger: | |
- platform: homeassistant | |
event: start | |
id: interval | |
- platform: homeassistant | |
event: shutdown | |
id: interval | |
- platform: time_pattern | |
id: interval | |
minutes: /9 | |
- platform: state | |
entity_id: | |
- media_player.music | |
from: paused | |
to: idle | |
id: idle | |
condition: [] | |
action: | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: | |
- interval | |
- condition: state | |
entity_id: media_player.music | |
state: paused | |
sequence: | |
- service: media_player.volume_mute | |
metadata: {} | |
data: | |
is_volume_muted: true | |
target: | |
entity_id: media_player.music | |
- if: | |
- condition: template | |
value_template: >- | |
{{ state_attr('media_player.music', 'supported_features') | | |
bitwise_and(2) }} | |
then: | |
- service: media_player.media_seek | |
metadata: {} | |
data: | |
seek_position: >- | |
{% set pos = state_attr('media_player.music', | |
'media_position')|int %} {{ pos if pos % 2 == 0 else pos - 1 | |
}} | |
target: | |
entity_id: media_player.music | |
else: | |
- service: media_player.media_play | |
metadata: {} | |
data: {} | |
target: | |
entity_id: media_player.music | |
- service: media_player.media_pause | |
metadata: {} | |
data: {} | |
target: | |
entity_id: media_player.music | |
- service: media_player.volume_mute | |
metadata: {} | |
data: | |
is_volume_muted: false | |
target: | |
entity_id: media_player.music | |
- conditions: | |
- condition: trigger | |
id: | |
- idle | |
sequence: | |
- service: media_player.volume_mute | |
metadata: {} | |
data: | |
is_volume_muted: true | |
target: | |
entity_id: media_player.music | |
- wait_for_trigger: | |
- platform: state | |
entity_id: | |
- media_player.music | |
to: playing | |
- delay: | |
hours: 0 | |
minutes: 0 | |
seconds: 2 | |
milliseconds: 0 | |
- service: media_player.media_pause | |
metadata: {} | |
data: {} | |
target: | |
entity_id: media_player.music | |
- delay: | |
hours: 0 | |
minutes: 0 | |
seconds: 1 | |
milliseconds: 0 | |
- service: media_player.volume_mute | |
metadata: {} | |
data: | |
is_volume_muted: false | |
target: | |
entity_id: media_player.music | |
mode: restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well now my speaker group seems to shut down after 10 hours? That's not so bad though.