hass-agent / HASS.Agent

Unofficial development project for the HASS.Agent platform.
https://hass-agent.io
MIT License
396 stars 12 forks source link

Bug: Media Player is_volume_muted #100

Open TarheelGrad1998 opened 5 months ago

TarheelGrad1998 commented 5 months ago

Please make sure that the issue you're planning to report is not already registered :)


Describe the bug For some reason, the is_volume_muted attribute of the media player entity does not update. The numeric volume_level however updates just fine. The separate sensor (audio_default_device_muted) does update however with some delay. I'm not sure if this is a bug or if it is something with my config. As a result, when I call the mute service it is always a toggle (and ignores the is_volume_muted parameter value), sometimes resulting in an undesired state.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior is_volume_muted attribute is updated in near real time.

Screenshots If applicable, add screenshots to help explain your problem.

Misc info (please complete the following information):

Please check what's applicable (multiple answers possible):

Additional context Add any other context about the problem here.

Logs If possible, please provide the logs of HASS.Agent and - if applicable - the Satellite Service. You can find HASS.Agent's logs by going to the main window, then Configuration -> Logging -> open logs folder. The Satellite Service's logs are in the same window, but the Satellite Service tab -> open service logs folder.

amadeo-alex commented 5 months ago

Fixed in 2.1.0-beta2 that will be released in a matter of days.

TarheelGrad1998 commented 4 months ago

I've just been setting my volume to 0 as a workaround, but finally tried the new beta. This still doesn't update for me, and now it seems neither does the volume level. It is always reported as 0, which breaks my workaround. :(

TarheelGrad1998 commented 1 month ago

It would have been nice if it were fixed, but I guess it's not going to be. Nice.

amadeo-alex commented 1 month ago

I'm sorry, I've missed your comment but I don't think I deserve the cynism. Issue was closed since I closed the 2.1.0 milestone, I'll reopen it and take a deeper look tomorrow.

amadeo-alex commented 1 month ago

I've just been setting my volume to 0 as a workaround, but finally tried the new beta. This still doesn't update for me, and now it seems neither does the volume level. It is always reported as 0, which breaks my workaround. :(

I've just tested on the 2.1.0 version and (delay between action-reaction is a bit less than one second):

With exception of the last one, that I think is a "new bug", is there anything not working for you?

TarheelGrad1998 commented 1 month ago

I just retested with 2.1.0 and my results match yours.

Long explanation: I had used the "set volume to 0" as a workaround for when muting wasn't working. I tested the beta-2 and neither muting nor the "set to 0" workaround worked for me. When I updated to 2.1.0 my "set to 0" workaround still wasn't working so I assumed none of it was. As it turns out, muting is working now so I've switched my automations to using that again. Thanks!

The only other oddness is calling the media_player.volume_mute is always a toggle regardless of what is passed for is_volume_muted. But it's easy to work around that by just checking the state before calling it. This may be a HA issue not a HASS.Agent issue, though.

TarheelGrad1998 commented 1 month ago

Hrm, then this morning, I decided to try to simplify my automations, and is_volume_muted was not updating. Based on the previous testing, I started playing a video in YouTube, and it did immediately update. It still updates as well if the YT video is paused. Once I closed YouTube, the sensor is not updating. I believe I did have a video up and paused during testing yesterday.

So the whole issue may be related to whether there is active media?

amadeo-alex commented 1 month ago

Sorry for the delay. So starting with

The only other oddness is calling the media_player.volume_mute is always a toggle regardless of what is passed for is_volume_muted.

Let me have a look, maybe at least I'll be able to verify where the issue is - although my hunch is on HASS.Agent or HASS.Agent integration.

It still updates as well if the YT video is paused. Once I closed YouTube, the sensor is not updating. I believe I did have a video up and paused during testing yesterday.

So the whole issue may be related to whether there is active media?

Yup, also something I noticed although this is purely "windows quirk". I'm still thinking if/how to approach this to be honest, maybe as part of the integration rewrite we could add a functionality to mute system when someone tries to mute "media player" but no media (from window's API perspective) is playing. Not 100% sure on that yet though.

amadeo-alex commented 1 month ago

Sorry for the delay. So starting with

The only other oddness is calling the media_player.volume_mute is always a toggle regardless of what is passed for is_volume_muted.

Let me have a look, maybe at least I'll be able to verify where the issue is - although my hunch is on HASS.Agent or HASS.Agent integration.

It still updates as well if the YT video is paused. Once I closed YouTube, the sensor is not updating. I believe I did have a video up and paused during testing yesterday.

So the whole issue may be related to whether there is active media?

Yup, also something I noticed although this is purely "windows quirk". I'm still thinking if/how to approach this to be honest, maybe as part of the integration rewrite we could add a functionality to mute system when someone tries to mute "media player" but no media (from window's API perspective) is playing. Not 100% sure on that yet though.

Let me have a look, maybe at least I'll be able to verify where the issue is - although my hunch is on HASS.Agent or HASS.Agent integration.

Both HASS.Agent itself and integration are at fault, looks like when it was originally coded the idea was to always toggle. I'll work on the fix.

amadeo-alex commented 1 month ago

Ok, I have POC ready and working (changes in both HASS.Agent and integration). I'll probably put this as part of beta2 of HASS.Agent and next release of integration that will also try to fix https://github.com/hass-agent/HASS.Agent/issues/178