ollo69/ha-samsungtv-smart

HDMI sources gone?

Closed this issue · 19 comments

Been using this for maybe 8 months without any issues. But when I tried using it yesterday the source-list from my TV was not visible. Only the default TV and HDMI is visible in the dropdown. Not my custom names for HDMI1 and HDMI2.
I have tried logging in to Smart Things on my phone, and I have no issue controling it from here.
Also opened the Smart Things app on the TV to confirm that I was still logged in.

The TV is a QN95B.

What can I do to solve this?

Thank you!

Probably you have problem with SmartThings registration of your TV, check it on your mobile device with SmartThings app.

Probably you have problem with SmartThings registration of your TV, check it on your mobile device with SmartThings app.

Everything looks correct on the SmartThings app. I can use my iPhone to control the TV via SmartThings without any issue. Is there something else I can check?

Error log, diagnostics...

I'm having the same issue. All of a sudden I'm not seeing any sources except TV and HDMI?

Same issue here. I can call the service "Media player: Select source" but it only responds to TV or HDMI, not HDMI2 or the configured names of the inputs/sources, which used to work. The TV sources are all listed correctly by ID and name in the diagnostic log, so the connection to the TV and the API is confirmed working, otherwise it wouldn't be able to see my custom source names, defined on the TV. I can also select the sources from the Smartthings app. Here's the relevant line from the diagnostics log:

2024-02-05 17:20:26.763 ERROR (MainThread) [custom_components.samsungtv_smart.media_player] Unsupported source

'supportedInputSourcesMap': {'value': '[{"id":"dtv","name":"TV"},{"id":"HDMI1","name":"PlayStation"},{"id":"HDMI2","name":"ha"},{"id":"HDMI3","name":"deck"},{"id":"HDMI4","name":"mac"}]'}

I used to be able to select the sources by the custom source names listed here. This text was copied from the diagnostics log, and it's current.

Error log, diagnostics...

Checking the debug log all my sources with their correct name is visible:
supportedInputSourcesMap': {'value': '[{"id":"dtv","name":"TV"},{"id":"HDMI1","name":"TV"},{"id":"HDMI2","name":"PS5"},{"id":"HDMI3","name":"AVR"}]'}

But they are not visible. Checking the config/diagnostic you can download from the integration page this is what shows up:
"state": { "state": "off", "attributes": { "source_list": [ "TV", "HDMI" ], "ip_address": "192.168.1.39", "device_class": "tv", "friendly_name": "Samsung QN95B", "supported_features": 90045 },

I can power on/off the TV via HA, so the connection is working. I can also put the TV in art mode via HA.

I installed pysmartthings and I can see my devices including the TV via the API, but I don't know the command to list the sources. I wanted to test to see if the problem is specific to samsungtv-smart or the cloud service. Anyone know the command to list sources?

import aiohttp
import pysmartthings
import asyncio

token = ‘redacted’

async def test():
    async with aiohttp.ClientSession() as session:
        api = pysmartthings.SmartThings(session, token)
        devices = await api.devices()
                
        if devices:  # Check if the list is not empty
            print(f"Total devices: {len(devices)}")
            for device in devices:
                print(f"Device ID: {device.device_id}")
                print(f"Name: {device.name}")
                print(f"Label: {device.label}")
                print(f"Capabilities: {device.capabilities}")
                print("----------")  
        else:
            print("No devices found.")


# Use asyncio.run() to handle the event loop correctly
asyncio.run(test())

I think that something is changed in the format of the message, I'll fix as soon I will have some available time.

This works to switch the input source via python:

import aiohttp
import asyncio
import json

async def set_input_source(token, device_id, new_input_source):
    url = f'https://api.smartthings.com/v1/devices/{device_id}/commands'
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }
    # Structure the payload with the command and its arguments
    payload = json.dumps({
        "commands": [{
            "component": "main",
            "capability": "samsungvd.mediaInputSource",  # Ensure this matches your device's capability
            "command": "setInputSource",
            "arguments": [new_input_source]  # The desired source to switch to
        }]
    })
    
    async with aiohttp.ClientSession() as session:
        async with session.post(url, headers=headers, data=payload) as response:
            if response.status in (200, 202):  # Success responses
                print("Input source changed successfully.")
                response_data = await response.json()
                print("Response:", response_data)
            else:
                print(f"Failed to change input source: HTTP {response.status}", await response.text())

# Example usage
token = ‘your_token’  # Your SmartThings API token
device_id = ‘your_deviceid’  # The ID of your device
new_input_source = 'PlayStation'  # Example input source, adjust as needed

asyncio.run(set_input_source(token, device_id, new_input_source))

Also, this is a useful utility for troubleshooting: https://my.smartthings.com/advanced

I am experiencing the same issue. It used to work fine. I see all the sources in logs correctly

{'value': '[{"id":"dtv","name":"TV"},{"id":"HDMI2","name":"PlayStation 5"},{"id":"HDMI3","name":"Apple TV"},{"id":"HDMI4","name":"Chromecast"}]'}

I added pyscript via HACS, then created services using the code I posted above, so now I can switch services again. I tried to figure out the problem with samsungtv-smart but I guess I'm not smart enough.

I should learn to read the GitHub documentation when I have problems. Noticed this issue today and spent hours trying to add back TVs to SmartThings only to eventually realise this issue here. Hope it will be fixed soon. I rely on this feature to auto update volume on my TV based on the hdmi source

Please try last release and report here if it fix the issue.

Yayy it fixed the issue for me. Thank you

PS: It doesn't work with my homekit bridge but maybe thats a homekit issue. I will try repairing the accessory

Thank you the input issue is fixed for me

Working again for me. Thank you

Ok, look this is solved, I close this issue.