MrSir
June 19, 2022, 11:16am
1
Hi everyone,
I’m looking to play an announcement (doorbell chime) over a google nest mini using the new announce
feature from 2022.6
However when media is playing through the speaker and the doorbell is pressed, the doorbell chime plays as expected but the media does not resume (the speaker stays silent).
This is my script:
play_doorbell_sound:
alias: Play Doorbell Sound
mode: single
sequence:
- service: media_player.play_media
target:
entity_id: media_player.kitchen_speaker
data:
media_content_id: media-source://media_source/local/dingdong.mp3
media_content_type: 'audio/mp3'
announce: true
Have I implemented it incorrectly?
Thank you
123
(Taras)
June 19, 2022, 1:33pm
2
You can read the following thread where the developers discuss how announce: true
should be handled by devices that don’t natively support the feature.
home-assistant:dev
← home-assistant:add-alert-media-player
opened 09:04PM - 26 May 22 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
<!--
If your PR contains a breaking change for existing users, it is important
to tell them what breaks, how to make it work again and why we did this.
This piece of text is published with the release notes, so it helps if you
write it towards our users, not us.
Note: Remove this section if this PR is NOT a breaking change.
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. **Your PR cannot be merged unless tests pass**
- [ ] There is no commented out code in this PR.
- [ ] I have followed the [development checklist][dev-checklist]
- [ ] The code has been formatted using Black (`black --fast homeassistant tests`)
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.
The integration reached or maintains the following [Integration Quality Scale][quality-scale]:
<!--
The Integration Quality Scale scores an integration on the code quality
and user experience. Each level of the quality scale consists of a list
of requirements. We highly recommend getting your integration scored!
-->
- [ ] No score or internal
- [ ] 🥈 Silver
- [ ] 🥇 Gold
- [ ] 🏆 Platinum
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [ ] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[manifest-docs]: https://developers.home-assistant.io/docs/en/creating_integration_manifest.html
[quality-scale]: https://developers.home-assistant.io/docs/en/next/integration_quality_scale_index.html
[docs-repository]: https://github.com/home-assistant/home-assistant.io
In brief, at this early stage, the feature only works if the target player supports it. If the player doesn’t support it then the announcement is simply played and doesn’t resume whatever was previously playing.
you can test the feature with https://github.com/music-assistant/hass-music-assistant which creates dedicated media_players based one the ha core players you feed it
123
(Taras)
June 19, 2022, 1:57pm
4
@MrSir be aware that the suggested custom component is still in development and if you use it now you will effectively be a beta tester. For example, its support for announce: true
still has a few challenges to overcome.
opened 06:13PM - 07 Jun 22 UTC
bug
For me TTS didn't work yet. If one of the players is running with the volume on … 100%, TTS attempt failed. This was the screen:
![image](https://user-images.githubusercontent.com/4363599/172453413-1ead7a8e-cb64-4408-8683-b8b596f3c642.jpeg)
When als players have their volume below 90%, the current queue is interrupted, but no announcement is played, and shortly later the music continues.
I noticed errors in the log:
```
Logger: homeassistant.components.websoc ket_api.http.connection
Source: components/cast/ media_player.py:502
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 20:25:14 (1 occurrences)
Last logged: 20:25:14
[547652456560] Error handling message: Unknown error (unknown_error)
Traceback (most recent call last):
File "/usr/src/homeassistant/ homeassistant/components/ websocket_api/decorators.py", line 27, in _handle_async_response
await func(hass, connection, msg)
File "/config/custom_components/ mass/websockets.py", line 98, in async_get_mass_func
await orig_func(hass, connection, msg, mass)
File "/config/custom_components/ mass/websockets.py", line 909, in websocket_playerqueue_command
await player_queue.player.volume_set(int( msg[COMMAND_ARG]))
File "/config/custom_components/ mass/player_controls.py", line 300, in volume_set
await self.hass.services.async_call(
File "/usr/src/homeassistant/
homeassistant/core.py", line 1704, in async_call
task.result()
File "/usr/src/homeassistant/
homeassistant/core.py", line 1741, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/ homeassistant/helpers/ entity_component.py", line 204, in handle_service
await service.entity_service_call( File "/usr/src/homeassistant/
homeassistant/helpers/service.py", line 680, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/ homeassistant/helpers/entity.py", line 964, in async_request_call
await coro
File "/usr/src/homeassistant/
homeassistant/helpers/service.py", line 717, in _handle_entity_call
await result
File "/usr/src/homeassistant/
homeassistant/components/ media_player/__init__.py", line 712, in async_set_volume_level
await self.hass.async_add_executor_ job( self.set_volume_level, volume)
File "/usr/local/lib/python3.9/ concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/ homeassistant/components/cast/ media_player.py", line 502, in set_volume_level
self._chromecast.set_volume(volum e)
File "/usr/local/lib/python3.9/site- packages/pychromecast/ controllers/receiver.py", line 181, in set_volume
self.send_message({MESSAGE_TYP E: "SET_VOLUME", "volume": {"level": volume}})
File "/usr/local/lib/python3.9/site- packages/pychromecast/ controllers/__init__.py", line 121, in send_message
self.send_message_nocheck( File "/usr/local/lib/python3.9/site-
packages/pychromecast/ controllers/__init__.py", line 133, in send_message_nocheck
self._message_func(
File "/usr/local/lib/python3.9/site-
packages/pychromecast/ socket_client.py", line 938, in send_platform_message
return self.send_message(
File "/usr/local/lib/python3.9/site-
packages/pychromecast/ socket_client.py", line 927, in send_message
raise NotConnected(f"Chromecast {self.host}:{self.port} is connecting...") pychromecast.error.NotConnected:
Chromecast 192.168.178.38:8009 is connecting...
```
I don’t mean to discourage you from trying it, only to inform you of what to expect.
Correct .
However , using HA we are all beta testers
And besides that, it’s currently the only integration supporting the feature.
It s also expected Music Assistant will be integrated into core Ha in the not too distant future so testing that is very much appreciated
Next to that does it allow you to do away with the core Spotify integration and the Radio stations which now are pretty but pretty underconfigurable too.
So a few quirks, and many perks!
123
(Taras)
June 19, 2022, 6:42pm
6
I look forward to being a “beta tester” when it becomes an official part of HA.
MrSir
June 19, 2022, 9:03pm
7
Thank you both!
I didn’t realise that announce wouldn’t be supported by all media_players (particularly ‘smart’ ones like google nest). Thank you for bringing this to my attention - it will save me wasting any more time.
I’ll have a look into this and see whether this is a suitable workaround (vs a manual “pause/play/resume” script for any announcements).
Thanks again
thats exactly what I had:
intercom_message:
alias: Intercom message
mode: restart
sequence:
- condition: state
entity_id: input_boolean.announce_intercom
state: 'on'
- condition: >
{{states(states('sensor.intercom')) not in ['unknown','unavailable']}}
# - service: script.pause_radio
# - service: script.pause_wakeup_radio
# - service: script.pause_spotify
- service: media_player.volume_set
data:
entity_id: >
{{states('sensor.intercom')}}
volume_level: >
{{states('input_number.intercom_volume')|float(0)}}
- service: tts.cloud_say #tts.google_say
data:
language: >
{{states('sensor.tts_language')}}
# {{states('input_select.intercom_language')|lower}}
options:
gender: >
{{states('input_select.tts_gender')|lower}}
entity_id: >
{{states('sensor.intercom')}}
# {{state_attr('sensor.intercom','entity_id')}}
message: >
{% set language = states('input_select.intercom_language') %}
{% if language == 'En' %} {{message_en}}
{% elif language == 'Nl' %} {{message_nl}}
{% else %} {{message_en}}
{% endif %}
# - service: script.resume_radio
# - service: script.resume_wakeup_radio
# - service: script.resume_spotify
and you can see the commented bits now taken care of in Music Assistant. At least, thats after ironing out some details
sensor.intercom here can be a single media player, or a group
note. it’s not yet supported by the core media_player entities. The same physical devices eg googlehome minis or others cant be controlled with the announce: true feature in core, but they are using that when embedded in Music assistant. You can even hide the core players in the config flow, to not have twice the media_players in your system, and only use the Mass media_players.
1 Like