Repository: music-assistant/support

Issue #2999: Synchronization Issues of Media Player States between MusicAssistant and HomeAssistant
Created: 2024-10-04T00:47:16Z
What version of Music Assistant has the issue?
2.3.0b29 (Tested on latest beta image)
What version of the Home Assistant Integration have you got installed?
2024.9.1 (Tested on latest HACS version)
Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

 Yes

The problem
Media Position is not synchronized correctly or updated frequently enough between MusicAssistant (MA) and HomeAssistant (HASS).
When adjusting the position of the current track in the MA web UI using the progress slider, the position is sometimes not transmitted to HASS or is not transmitted correctly. The same problem also exists the other way around.

Since the media_position is not updated regularly, it is only estimated in HASS based on the timestamp (media_position_updated_at), and there may be discrepancies between the progress indicator in HASS and MA.
It would probably be more robust to synchronize progress at a minimum interval of 10 seconds, for example.
How to reproduce
Change the progress bar in mediaplayer states via the Web-UI of MA or HASS and observe the reaction on the other side.
Music Providers
Tested with Spotify
Player Providers
Tested with Snapcast
Full log output
No response
Additional information
Home Assistant is authenticated as plugin provider in MA
What version of Home Assistant Core are your running
2024.9.3
What type of installation are you running?
Home Assistant Container
On what type of hardware are you running?
Linux

Duplicate issue #3704: media_position attribute is not correctly updated
Created: 2025-03-10T13:18:09Z
This report started with the below but after further testing the cast player also was noticed to be not updating the media_position attribute when seeking. Using the media_player.media_seek action often resulted in the attribute not updating even though the track was advanced (or rewinded). When pausing the player the attribute seems to always be updated correctly.
============================================
What I think happens is at the point of enqeuing the next track the media position of the curently playing track is put into the attribute. Pausing and resuming the track results in the value being set correctly.
Steps to reproduce:
Use a picoreplayer as a player
Add two tracks to the queue
Observe the first track has all attributes with appropriate values
At the point where the next track is queued observe that the media_position updates to a value close to the duration of the first track.
Pause and resume the player
Observe that the media_position changes to an appropriately low number
Use the following template to compare to the MA UI
{% set media_position = state_attr('media_player.ma_study_player_provsp', 'media_position') | float(0) %}
{% set elapsed_time = (utcnow() - state_attr('media_player.ma_study_player_provsp', 'media_position_updated_at')).total_seconds() %}
{% set total_time = media_position + elapsed_time %}

{{ total_time | timestamp_custom('%M:%S', false) }} 

Discussed in https://github.com/orgs/music-assistant/discussions/3702

Originally posted by msknight March 10, 2025
I'm not sure if this is an MA issue or where else I go for this.
I have a squeezelite player on a raspberry Pi, configured in MA. Ma is playing the audio to it, but the progress bar is way off. This is the hardware and software I'm using - https://msknight.com/ha/ma-5.html
On examining the state, it seems that the position is higher than the duration. It's like this for a lot of things. I'm not sure if this is an MA issue or if I need to go elsewhere to raise the issue.
Grateful for any pointers.

Closing comment (2025-04-11T23:26:19Z): Possibly related to #2999