samuelspagl / ha_samsung_soundbar

YASSI (Yet another Samsung Soundbar integration) is a HomeAssistant integration for Samsung Soundbars.
https://ha-samsung-soundbar.vercel.app
MIT License
44 stars 2 forks source link

[FEATURE]: Add input state "wifi" for given apps as smarthings api doesn't report it correctly #14

Closed bishengliu7 closed 8 months ago

bishengliu7 commented 9 months ago

I'm using sound bar Q990B, when I do AirPlay, the ha device would have empty input source showing, while other input sources like bluetooth or digital worked well. Here's some screenshot in HA:
20240208-112925

entity state history: image

should be a same issue as https://github.com/PiotrMachowski/Home-Assistant-custom-components-SmartThings-Soundbar/issues/52

samuelspagl commented 9 months ago

Hi @bishengliu7

I know of this problem, and its the same thing with my soundbar (Q935). The thing is that the Smartthings API (for some reason I don't understand) is not returning wifi when using AirPlay or Spotify but "".

Thinking about it, I could make an extra step and still return wifi if the app is spotify or airplay.

The proposed changed would be something like this in the SoundbarDevice.py

    @property
    def input_source(self):
        if self.media_app_name() in ("airplay", "spotify"):  # added
            return "wifi"                                                             # added
        return self.device.status.input_source

This is a bit "hacky", but it could / should work.

I will try it out as soon as possible.

samuelspagl commented 9 months ago

Hi @bishengliu7,

I released a new beta version, where I fixed this issue / feature. You can try it out and tell me if it works for you.

https://github.com/samuelspagl/ha_samsung_soundbar/releases/tag/0.3.0b2

For more information on how to install a "pre-release" please read the official HACS documentation.

Hope that helps.

bishengliu7 commented 9 months ago

Hi @bishengliu7,

I released a new beta version, where I fixed this issue / feature. You can try it out and tell me if it works for you.

https://github.com/samuelspagl/ha_samsung_soundbar/releases/tag/0.3.0b2

For more information on how to install a "pre-release" please read the official HACS documentation.

Hope that helps.

SGTM, i'll try that today. Thanks for the fast response!

bishengliu7 commented 9 months ago

image image

seems not working, the value of input preset is still unknown

image i moved the beta version to custom_components directory and rebooted my ha

samuelspagl commented 9 months ago

Can you try one thing for me please. Do you have the SmartThings App on your mobile Device? Could you open it, tap on your Soundbar (given that you stream music with AirPlay or Spotify) and take a look if something changes?

Interestingly I saw on my end that, the media_app, in my case AirPlay or Spotify sometimes is only being reported when the SmartThings App was opened.

Can you show me the complete state of the media_player entity?

Thanks a lot!

bishengliu7 commented 9 months ago

Seems also my case! that's tricky... when soundbar is off: image when airplay without turning on app image after opening app and tap the sound bar image

samuelspagl commented 9 months ago

But the source now is listed correctly as wifi in the third image.

samuelspagl commented 9 months ago

So this is again a case of "What the heck is the SmartThings API doing?" for me 😄. Until now I thought that it was maybe just my device, but as you can confirm the same behavior, it's official 😅.

So honestly I don't know how to make a change / fix this entirely. I know that there are API commands that control / fetch info for every aspect of the soundbar, but as they are not listed anywhere its kinda hard to guess.

bishengliu7 commented 9 months ago

yeah...seems the media type is not updated as soon as input source changed

bishengliu7 commented 9 months ago

I'm wondering if it is possible to add a default input source? so we can some how hack it in the HA automation, like treat the default input source as airplay. Currently it is 'unknown' seems not able to be used as a condition in automation

samuelspagl commented 9 months ago

Let me think about that. So I'm not sure about the naming, but I think that I would be fine to add the "unknown" state to the souce_list and specifically set it as a value if nothing is returned by the SmartThings API.