Yah, I figured. I do the same thing and always add the same kind of typos
Amazing!
Two of the best template masters on the community collaborating on the same post haha
Great job guys.
⌠and since this thread is about your media_players, hereâs how your scripts appear when they use groups and the expand
function. They are reduced in size, easier to read, and easier to maintain.
Groups
players_all:
name: Media Players All
entities:
- media_player.banheiro_social
- media_player.banheiro_da_suite
- media_player.cozinha
- media_player.quarto
- media_player.sala
- media_player.suite
players_main:
name: Media Players Main
entities:
- media_player.banheiro_social
- media_player.cozinha
- media_player.quarto
- media_player.sala
Scripts
ghm_play_media:
sequence:
- condition: template
value_template: "{{ not is_state('media_player.casa_inteira' , 'playing')}}"
- service: media_player.volume_set
data_template:
entity_id: >-
{{ expand('group.players_all') | selectattr('state','!=','playing') | map(attribute='entity_id') | join(', ') }}
volume_level: '{{volume}}'
- service: media_player.play_media
data_template:
entity_id: >-
{% set players = expand('group.players_all') | list %}
{% set not_playing = players | selectattr('state','!=','playing') | list %}
{% if is_state('input_boolean.boa_noite', 'on') %}
{{ expand('group.players_main') | selectattr('state','!=','playing') | map(attribute='entity_id') | join(', ') }}
{% else %}
{% if not_playing | count == players | count %}
media_player.casa_inteira
{% else %}
{{ not_playing | map(attribute='entity_id') | join(', ') }}
{% endif %}
{% endif %}
media_content_type: 'audio/mp3'
media_content_id: '{{media}}'
ghm_tts:
sequence:
- condition: template
value_template: "{{ not is_state('media_player.casa_inteira' , 'playing')}}"
- service: media_player.volume_set
data_template:
entity_id: >-
{{ expand('group.players_all') | selectattr('state','!=','playing') | map(attribute='entity_id') | join(', ') }}
volume_level: '{{volume}}'
- service: tts.amazon_polly_say
data_template:
entity_id: >-
{% set players = expand('group.players_all') | list %}
{% set not_playing = players | selectattr('state','!=','playing') | list %}
{% if is_state('input_boolean.boa_noite', 'on') %}
{{ expand('group.players_main') | selectattr('state','!=','playing') | map(attribute='entity_id') | join(', ') }}
{% else %}
{% if not_playing | count == players | count %}
media_player.casa_inteira
{% else %}
{{ not_playing | map(attribute='entity_id') | join(', ') }}
{% endif %}
{% endif %}
message: '{{tts}}'
Thank you very much!
I was about to try this solution this weekend and youâve helped me a great deal!
Iâll let you know if it works
Thanks again!
Hello guys!
I was only able to deploy this solution as of today
It works beautifully! Great job!
Thanks a lot again.
This is a very nice piece of work. I am working on implementing right now.
I assume the service call for above scriptâs would be:
- service: script.ghm_play_media
data_template:
media: 'http://path to file'
volume: 5
And the call for tts would be:
- service: script.ghm_tts
data_template:
tts: 'make me smile'
volume: 5
My question is can the volume be templated as well? I usually donât mess with the volume of my speakers (I have google minis) but if the volume is accidentally turned all the way down, they canât hear anything. I was thinking an option where the script sets the volume ONLY if current is lower than requested. So I send volume 5 and if the volume is currently at 3, it bumps it to 5, but if itâs at 7, it leaves it alone. Is that possible??
As it is I will be commenting out the volume setting, but this would be nice option in this new awesome tool.
I plan on sending this out as YouTube video in the near future assuming there are no objections. This problem is everywhere out there and I would like to spread the word. I will of course site this article and pull people here for further information.
Thanks for the great work!
https://www.WhatAreWeFixing.Today/
As we are now over a year since this thread,
Did any one come up with a âout of the boxâ solution for that? blueprint or add-ons of any kind?