Closed brunoccr closed 2 years ago
mpd documentation mpd source (message by IssueLinks)
Hey there @fabaff, mind taking a look at this issue as it has been labeled with an integration (mpd
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
I am also having this issue when calling the media_player.play_media
service on an MPD device via Node-RED with a file
URI:
Error output:
This issue appears to be affecting me as well.
2022-04-07 18:46:20 ERROR (MainThread) [homeassistant.components.automation.wind_down_music] Wind Down Music: Error executing script. Unexpected error for call_service at pos 1: URL is relative, but does not start with a /
Traceback (most recent call last):
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/helpers/script.py", line 379, in _async_step
await getattr(self, handler)()
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/helpers/script.py", line 582, in _async_call_service_step
await service_task
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/core.py", line 1634, in async_call
task.result()
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/core.py", line 1671, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/helpers/entity_component.py", line 204, in handle_service
await service.entity_service_call(
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/helpers/service.py", line 677, in entity_service_call
future.result() # pop exception if have
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/helpers/entity.py", line 955, in async_request_call
await coro
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/helpers/service.py", line 714, in _handle_entity_call
await result
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/components/mpd/media_player.py", line 479, in async_play_media
media_id = async_process_play_media_url(self.hass, media_id)
File "/srv/homeassistant/lib64/python3.9/site-packages/homeassistant/components/media_player/browse_media.py", line 40, in async_process_play_media_url
raise ValueError("URL is relative, but does not start with a /")
Relevant automation:
- alias: Wind Down Music
initial_state: True
trigger:
platform: event
event_type: MY_WIND_DOWN
action:
- service: media_player.play_media
data:
entity_id: media_player.mainmusic
media_content_type: music
media_content_id: >
{{ [
"local:track:Mixes/Sleep/Classical%20music%20for%20babies%20-%20Toddler%20bedtime.mp3",
"local:track:Mixes/Sleep/Relaxing%20Music%20For%20Children%20-%20Be%20Calm%20and%20Focused%20%28cute%20animals%29.mp3"
] | random }}
Same issue for me: URL is relative, but does not start with a /
I was sending my MPD instance the command play_media
for a spotify with the format spotify:playlist:XXXXXXXXX
I think part of the issue is when calling the play_media service with a "local" url there isn't a way to specify whether it means local to your HA instance or local to the media player. I got around the issue by modifying the condition here https://github.com/home-assistant/core/blob/689b347904857c77c1346f3f1e971f2dc31d49ca/homeassistant/components/media_player/browse_media.py#L35. Basically I just check if the url has a "scheme" and pass through the media ID if it does. I have a feeling that probably won't work for everyone, especially if you use a "file://" url for referring to files on your HA instance. This might be an issue that is specific to MPD since mopidy seems to use some kind of weird URLs for media IDs, so maybe it would make more sense to put change the logic in just the MPD component?
I am using mopidy with MPD.
Adding a preceding /
allows to service call to execute, but then it does not successfully play the request.
The problem
On pass music name as media_id occurr error
What version of Home Assistant Core has the issue?
core-2022.4.0
What was the last working version of Home Assistant Core?
core-2022.3.8
What type of installation are you running?
Home Assistant OS
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
I believe this line is incorrect.