PiotrMachowski / Home-Assistant-custom-components-SmartThings-Soundbar

Samsung Smarthings API for controlling Soundbar
MIT License
89 stars 23 forks source link

Cannot switch the input source to 'wifi' on Soundbar Q80R #25

Open buentead opened 2 years ago

buentead commented 2 years ago

Using the service media_player.select_source I can switch the input source of my Samsung Q80R soundbar to hdmi1 and hdmi2. But I'm unable to switch to wifi. Also I'm unable to switch to digital.

Note: I'm able to switch to any input source using the Samsung SmartThings App on my mobile phone.

Thank you for your work done!

PiotrMachowski commented 2 years ago

Are there any errors in logs?

buentead commented 2 years ago

No, unfortunately not. I checked in /config/logs and on hassio/system.

buentead commented 2 years ago

I run the API by POSTMAN myself:

HTTP POST https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/commands
{
    'commands': [
        {
            'component': 'main',
            'capability': 'mediaInputSource',
            'command': 'setInputSource',
            'arguments': [
                'wifi'
            ]
        }
    ]
}

Which returns:

HTTP status: 200 OK
{
    "results": [
        {
            "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "status": "ACCEPTED"
        }
    ]
}

Although the status returned is ACCEPTED, the device remains in the previous input source. It can be confirmed by the device status, that the source hasn't changed. Now, I assume it is a problem on the Soundbar Q80R itself and not in your component.

Do you know what the problem may be?

PiotrMachowski commented 2 years ago

Sometimes they act wonky, you can try resetting it and it might be ok after adding it to SmartThings again

haakonhh commented 2 years ago

I have exactly the same problem on my HW-Q70R (HW-Q76R). I belive this worked a while ago, but the last weeks/month i can no longer change input to wifi from this component. I have tried to factory reset the soundbar, but the issue still persists. Change of input from the SmartThings app works, so that makes it even more strange.

buentead commented 2 years ago

After some "try and error" hours, I came up with the following solution:

Use Case: Play radio station directly on the Samsung Q80R soundbar using WiFi

Installation / Configuration

  1. Configure the Samsung Q80R soundbar using the Samsung SmartThings App, e.g. configure the WiFi settings
  2. Install the SmartThings Soundbar from @PiotrMachowski (my entity ID: media_player.smartthingq80r)
  3. Configure the DLNA Digital Media Renderer for the same Q80R (my entity ID: media_player.av_samsung_soundbar_q80r)

Script to listen to Internet radio stations on Samsung Q80R through WiFi

radio_on:
  alias: radio_on
  sequence:
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.smartthingq80r
  - service: media_player.volume_set
    data:
      volume_level: 0.35
    target:
      entity_id:
      - media_player.smartthingq80r
  - service: media_player.play_media
    data_template:
      entity_id: "{% if is_state(\"input_select.dlna_render\", \"Wohnzimmer\") %}\n\
        \  media_player.av_samsung_soundbar_q80r\n{% elif is_state(\"input_select.dlna_render\"\
        , \"Büro\") %}\n  media_player.av_samsung_soundbar_q80r\n{% endif %}\n"
      media_content_id: "{% if is_state(\"input_select.radio_station\", \"SRF1\")\
        \ %}\n  http://stream.srg-ssr.ch/m/regi_zentr/aacp_96\n{% elif is_state(\"\
        input_select.radio_station\", \"SRF2\") %}\n  http://stream.srg-ssr.ch/m/drs2/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"SRF3\") %}\n  http://stream.srg-ssr.ch/m/drs3/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"SRF4\") %}\n  http://stream.srg-ssr.ch/m/drs4news/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"SwissPop\") %}\n  http://stream.srg-ssr.ch/m/rsp/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"SwissJazz\") %}\n  http://stream.srg-ssr.ch/m/rsj/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"SwissClassic\") %}\n  http://stream.srg-ssr.ch/m/rsc_de/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"Musikwelle\") %}\n  http://stream.srg-ssr.ch/m/drsmw/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"SRFVirus\") %}\n  http://stream.srg-ssr.ch/m/drsvirus/aacp_96\n\
        {% elif is_state(\"input_select.radio_station\", \"RadioPilatus\") %}\n  http://radiopilatus.ice.infomaniak.ch/pilatus128.mp3\n\
        {% endif %}\n"
      media_content_type: music

Using the DLNA entity to play a media from the Internet, the Samsung Q80R switches to WiFi itself. However, the display of the device may not show WiFi. But it works :-)

When I switch off the radio, I set the source to 'digital' using the entity ID media_player.smartthingq80r. This is required, as the TV is connected through the optical interface.

salvq commented 2 years ago

@buentead thank you for the guide however I was not able to set the media renderer in point 3, can you help to clarify.

How did you set the samsung as DLNA Renderer ? I have missing soundbar in the list in HA however my samsung is visible in network, also in smartthings and have working integration from PiotrMachowski

image

buentead commented 2 years ago

You need to add the DLNA Digital Media Renderer. Then, the Soundbar will be discovered automatically.

salvq commented 2 years ago

You need to add the DLNA Digital Media Renderer. Then, the Soundbar will be discovered automatically.

Actualy this is what I did and got the output above...samsung soundbar did not showed up in the list of supported devices. Have you enabled the dlna for samsung somewhere ?

buentead commented 2 years ago

No. Not that I'm aware off. Could it be, that your device is ignored or disabled from the HA Integration? image

In my situation, the soundbar just showed up; I got a message, that a new device was discovered and it was listed there.

Is your soundbar in the same LAN subnet as HA so it can be 'seen'?

salvq commented 2 years ago

It is indeed, I can ping it.

I tried the disabled as you suggested and it is not there, I do not get it because other devices are showing up.

Could it be that I have HW-900a and it does not support DLNA ? How to find out if device support DLNA ?

Thanks

buentead commented 2 years ago

I'm using the iPhone App uPnP Mate (Version 1.1.3) from YLWong Consulting to discover and verify the my UPNP/DLNA devices.

salvq commented 2 years ago

Using uPnP devices showed up interesting thing, looks like HW-Q900a does not support DLNA which is very suprising considering that this is one of the Samsung high end subwoofers :(

Device is specified like dialreceiver not MediaRenderer, I am waiting for feedback from support to clarify...

image

buentead commented 2 years ago

Thanks for the feedback. I never saw 'dialreceiver' as a device in my environment. Is this a device using the Discovery and Launch (DIAL) protocol developed by Netflix and YouTube with the help from Sony and Samsung? Will be interesting to hear from Samsung support.

salvq commented 2 years ago

I got a feedback that Q900a does not support DLNA. However I made a request to the development team to make Q900a DLNA capable but doubt that this will happen