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
41 stars 2 forks source link

Update custom capabilities (soundmode, woofer, eq, advanced_audio) fails #26

Closed royf007 closed 3 months ago

royf007 commented 5 months ago

So, I have been using this great integration with no issues on 2 Samsung Q990C soundbars for a few weeks.

I recently bought a 3rd Q990C. It's on the same network, same firmware version as the other 2. I'm able to use the Yamaha MusicCast API (api.smartthings.com) through Postman, obtain the device ID, send commands, etc. I'm also able to see it in the SmartThings integration in Home Assistant.

When I go to try to add the 3rd soundbar to this integration as a new "hub", it always fails to configure. I've even tried to remove and add back the other 2 soundbars that were previously working, and there are no issues adding them back.

I'm not really sure why I can't add this 3rd soundbar.

Any help would be appreciated. Here is the log entry:

Log Entry ``` Logger: homeassistant.config_entries Source: config_entries.py:504 First occurred: 12:13:07 AM (4 occurrences) Last logged: 12:15:29 AM Error setting up entry samsung_soundbar for samsung_soundbar Error setting up entry Living Room Soundbar for samsung_soundbar Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/samsung_soundbar/__init__.py", line 52, in async_setup_entry await soundbar_device.update() File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 52, in update await self._update_soundmode() File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 74, in _update_soundmode payload = await self.get_execute_status() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 390, in get_execute_status return dict["data"]["value"]["payload"] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable ```
samuelspagl commented 5 months ago

Hi @royf007,

Okay, then lets try to do this step by step. are

samsung_soundbar or Living Room Soundbar

The name of the first, second or third entries?

And was one of those Soundbars completely cut off from the powersource?

royf007 commented 5 months ago

Hi @samuelspagl , so I confirmed that the Living Room soundbar is powered on and useable in SmartThings. What I just tried was deleting the integration and all associated entities, then re-installing the integration, and just trying to add the Living Room soundbar by itself. I'm still getting the same error:

Logs ``` Logger: homeassistant.config_entries Source: config_entries.py:504 First occurred: 9:26:19 AM (2 occurrences) Last logged: 9:26:34 AM Error setting up entry samsung_soundbar for samsung_soundbar Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/samsung_soundbar/__init__.py", line 52, in async_setup_entry await soundbar_device.update() File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 52, in update await self._update_soundmode() File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 74, in _update_soundmode payload = await self.get_execute_status() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 390, in get_execute_status return dict["data"]["value"]["payload"] ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable ```

Please let me know if there are any additional debugging steps you would like me do.

royf007 commented 5 months ago

Hi @samuelspagl , so I did some more troubleshooting, and here is what I found:

In /config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py, the function at line 385 is used for status:

    async def get_execute_status(self):
        url = f"https://api.smartthings.com/v1/devices/{self._device_id}/components/main/capabilities/execute/status"
        request_headers = {"Authorization": "Bearer " + self._api_key}
        resp = await self.__session.get(url, headers=request_headers)
        dict = await resp.json()
        return dict["data"]["value"]["payload"]

For the other 2 Samsung Q990C soundbars that I have (Master Bedroom and Gym, the API call to the SmartThings API returns data. For the Living Room soundbar, the calls succeeds but it returns no data. This is where the setup for the Living Room soundbar is failing during setup in the HA Samsung Soundbar integration.

For the 2 working soundbars, the call to: https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/capabilities/execute/status returns the following:

Response body ``` { "data": { "value": { "payload": { "rt": [ "x.com.samsung.networkaudio.eq" ], "if": [ "oic.if.rw", "oic.if.baseline" ], "x.com.samsung.networkaudio.supportedList": [ "NONE", "POP", "JAZZ", "CLASSIC" ], "x.com.samsung.networkaudio.EQname": "NONE", "x.com.samsung.networkaudio.action": "setEQmode", "x.com.samsung.networkaudio.EQband": [ "0", "0", "0", "0", "0", "0", "0" ] } }, "data": { "href": "/sec/networkaudio/eq" }, "timestamp": "2024-03-26T09:15:00.030Z" } } ```

For the Living Room soundbar, for the same call, the following is returned:

{
    "data": {
        "value": null
    }
}

Question:

Can the code be modified to ignore the empty response, so that the soundbar setup can complete correctly? The Living Room soundbar is working perfectly and as I mentioned before, no issues in Home Assistant with the SmartThings integration.

Also, in the SmartThings API, there is an alternate method for status that I've used successfully for all 3 soundbars: https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/status

samuelspagl commented 5 months ago

Nice, thanks for all of the information.

This would correspond with another issue, because in the end, I would probably make the config adjustable in a way that it possible to disable certain features like the EQ.

But I dunno how fast I can get it to work. I would hope to work on it tomorrow or on saturday a bit, but I also have other things on the ToDo list.

royf007 commented 5 months ago

You're welcome. Really, it's no rush. I appreciate your quick response and all the work you've put into this integration!

samuelspagl commented 5 months ago

Was it possible for you to retrieve the same data with:

https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/status

As with the other status call currently used?

royf007 commented 5 months ago

For the https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/status call, it returns a ton of information...practically everything.

The call that the integration is currently using returns a minimal amount of "supported" network audio supported modes, but these soundbars don't even have these sound program settings in the SmartThings app, so I would say the current https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/capabilities/execute/status adds no additional value. For example, it returns ONLY:

{
    "data": {
        "value": {
            "payload": {
                "rt": [
                    "x.com.samsung.networkaudio.eq"
                ],
                "if": [
                    "oic.if.rw",
                    "oic.if.baseline"
                ],
                "x.com.samsung.networkaudio.supportedList": [
                    "NONE",
                    "POP",
                    "JAZZ",
                    "CLASSIC"
                ],
                "x.com.samsung.networkaudio.EQname": "NONE",
                "x.com.samsung.networkaudio.action": "setEQmode",
                "x.com.samsung.networkaudio.EQband": [
                    "0",
                    "0",
                    "0",
                    "0",
                    "0",
                    "0",
                    "0"
                ]
            }
        },
        "data": {
            "href": "/sec/networkaudio/eq"
        },
        "timestamp": "2024-03-26T09:15:00.030Z"
    }
}

and nothing can be done with these settings anyway.

samuelspagl commented 5 months ago

Interesting because a call against https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/status returns a status_code 200 without any data for me. (Of course I used my own device-id ^^)

Can you show me what exactly this url is returning?

About the data of for example the eq in this case and the https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/capabilities/execute/status api-call.

This is currently to my knowledge the only way I can retrieve the information of Soundmodes, Subwoofer, EQ, and the switches (Nightmode etc.).

I'm still trying to figure my way in the SmartThings API because many things are a bit "not" straight-forward. Like for example retrieving the information of the Soundmode:

I need to first hit the https://api.smartthings.com/v1/devices/{deviceId}/commands endpoint with a certain body:

Expand ``` data = { "commands": [ { "component": component_id, "capability": capability, "command": command, "arguments": ["/sec/networkaudio/advancedaudio"] } ] } ```

If I understood it correctly (and those are just assumptions) then as this call does not return any useful information, it retrieves the in the argument selected information from the soundbar and adds it to the status.

I do this "dance" for all of the above mentioned "extra" capabilities. Changing the properties of one of those also uses the https://api.smartthings.com/v1/devices/{deviceId}/commands endpoint with a slightly different body.

I did not find a way to retrieve the information of Soundmodes, Subwoofer, EQ, and the switches (Nightmode etc.) all at once.

Is https://api.smartthings.com/v1/devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/components/main/status retrieving all of those "extra" information for you?

samuelspagl commented 5 months ago

Btw. I would edit some of your comments and hide the bigger code parts in a

tag.

royf007 commented 5 months ago

Thanks for the tip on using the details markdown tag. So, the response that I'm getting from the call:

Response for call to https://api.smartthings.com/v1/devices/{deviceId}/components/main/status ``` { "mediaPlayback": { "supportedPlaybackCommands": { "value": [ "play", "pause", "stop" ], "timestamp": "2024-03-28T14:33:58.913Z" }, "playbackStatus": { "value": "stopped", "timestamp": "2024-03-28T14:33:58.913Z" } }, "samsungvd.soundFrom": { "mode": { "value": 1, "timestamp": "2024-03-28T17:23:52.738Z" }, "detailName": { "value": "External Device", "timestamp": "2024-03-28T14:41:14.844Z" } }, "audioVolume": { "volume": { "value": 28, "unit": "%", "timestamp": "2024-03-28T18:05:37.725Z" } }, "samsungvd.deviceInfoPrivate": {}, "mediaInputSource": { "supportedInputSources": { "value": [ "digital", "HDMI1", "bluetooth", "wifi", "HDMI2" ], "timestamp": "2024-03-28T14:33:58.512Z" }, "inputSource": { "value": "digital", "timestamp": "2024-03-28T16:00:05.902Z" } }, "samsungvd.audioPlayback": {}, "refresh": {}, "audioNotification": {}, "execute": { "data": { "value": null } }, "samsungvd.audioInputSource": { "supportedInputSources": { "value": [ "digital", "HDMI1", "bluetooth", "wifi", "HDMI2" ], "timestamp": "2024-03-28T14:33:58.512Z" }, "inputSource": { "value": "digital", "timestamp": "2024-03-28T16:00:05.902Z" } }, "switch": { "switch": { "value": "on", "timestamp": "2024-03-28T15:59:59.817Z" } }, "ocf": { "st": { "value": "1970-01-01T00:00:34Z", "timestamp": "2024-03-28T14:33:58.382Z" }, "mndt": { "value": "2023-01-01", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnfv": { "value": "SAT-iMX8M23WWC-1004.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnhw": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "di": { "value": "36dcc95d-74b4-0b94-b397-7e6c6bb931c9", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnsl": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "dmv": { "value": "res.1.1.0,sh.1.1.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "n": { "value": "Q-Series Soundbar", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnmo": { "value": "HW-Q990C", "timestamp": "2024-03-28T14:33:58.382Z" }, "vid": { "value": "VD-NetworkAudio-002S", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnmn": { "value": "Samsung Electronics", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnml": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnpv": { "value": "7.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnos": { "value": "Tizen", "timestamp": "2024-03-28T14:33:58.382Z" }, "pi": { "value": "36dcc95d-74b4-0b94-b397-7e6c6bb931c9", "timestamp": "2024-03-28T14:33:58.382Z" }, "icv": { "value": "core.1.1.0", "timestamp": "2024-03-28T14:33:58.382Z" } }, "samsungvd.audioSoundFrom": {}, "audioMute": { "mute": { "value": "unmuted", "timestamp": "2024-03-28T16:00:00.010Z" } }, "samsungvd.thingStatus": { "updatedTime": { "value": 1711644738, "timestamp": "2024-03-28T16:52:17.828Z" }, "status": { "value": "Idle", "timestamp": "2024-03-28T14:33:58.409Z" } }, "audioTrackData": { "totalTime": { "value": 0, "timestamp": "2024-03-28T14:34:00.521Z" }, "audioTrackData": { "value": { "title": "", "artist": "", "album": "" }, "timestamp": "2024-03-28T14:34:00.521Z" }, "elapsedTime": { "value": 0, "timestamp": "2024-03-28T14:33:58.913Z" } } } ```

I've been combing through the SmartThings API, and there was another method which seems similar: https://api.smartthings.com/v1/devices/{deviceId}/status .

It looks like for my Living Room soundbar, the following section is missing from the response (which I presume is what you are trying to get from your call for the extra capabilites):

Response Needed for Extra Capabilities? ``` "execute": { "data": { "value": { "payload": { "rt": [ "x.com.samsung.networkaudio.eq" ], "if": [ "oic.if.rw", "oic.if.baseline" ], "x.com.samsung.networkaudio.supportedList": [ "NONE", "POP", "JAZZ", "CLASSIC" ], "x.com.samsung.networkaudio.EQname": "NONE", "x.com.samsung.networkaudio.action": "setEQmode", "x.com.samsung.networkaudio.EQband": [ "0", "0", "0", "0", "0", "0", "0" ] } }, "data": { "href": "/sec/networkaudio/eq" }, "timestamp": "2024-03-26T09:15:00.030Z" } } ```

I'm just puzzled because the 3 soundbars are identical, on the same firmware version. I've even removed the Living Room soundbar from SmartThings, and added it back. So at this point, I'm still not sure how to get the subwoofer, night mode, and other enhanced settings from this 1 soundbar.

samuelspagl commented 5 months ago

Okay can you try one thing for me:

First again make your https://api.smartthings.com/v1/devices/{deviceId}/components/main/status

Then a call against https://api.smartthings.com/v1/devices/{deviceId}/commands with the following body

{
        "commands": [
            {
                "component": "main",
                "capability": execute,
                "command": execture,
                "arguments": ["/sec/networkaudio/eq"]
            }
        ]
    }

Then retrigger your https://api.smartthings.com/v1/devices/{deviceId}/components/main/status In the response body under execute.data.value should now hopefully be the eq section listed. (this section should be empty before, as it is in your upper response body)

And then can you call this endpoint https://api.smartthings.com/v1/devices/{deviceId}/components/main/capabilities/execute/status It should be exactly the same as the execute section.

royf007 commented 5 months ago

Ok, please see the results from my testing below:

First HTTP GET call (/devices/{deviceId}/components/main/status)
GET Request: https://api.smartthings.com/v1/devices/{deviceId}/components/main/status

Response: ```json { "mediaPlayback": { "supportedPlaybackCommands": { "value": [ "play", "pause", "stop" ], "timestamp": "2024-03-28T14:33:58.913Z" }, "playbackStatus": { "value": "stopped", "timestamp": "2024-03-28T14:33:58.913Z" } }, "samsungvd.soundFrom": { "mode": { "value": 1, "timestamp": "2024-03-28T17:23:52.738Z" }, "detailName": { "value": "External Device", "timestamp": "2024-03-28T14:41:14.844Z" } }, "audioVolume": { "volume": { "value": 28, "unit": "%", "timestamp": "2024-03-28T18:05:37.725Z" } }, "samsungvd.deviceInfoPrivate": {}, "mediaInputSource": { "supportedInputSources": { "value": [ "digital", "HDMI1", "bluetooth", "wifi", "HDMI2" ], "timestamp": "2024-03-28T14:33:58.512Z" }, "inputSource": { "value": "digital", "timestamp": "2024-03-28T16:00:05.902Z" } }, "samsungvd.audioPlayback": {}, "refresh": {}, "audioNotification": {}, "execute": { "data": { "value": null } }, "samsungvd.audioInputSource": { "supportedInputSources": { "value": [ "digital", "HDMI1", "bluetooth", "wifi", "HDMI2" ], "timestamp": "2024-03-28T14:33:58.512Z" }, "inputSource": { "value": "digital", "timestamp": "2024-03-28T16:00:05.902Z" } }, "switch": { "switch": { "value": "on", "timestamp": "2024-03-28T15:59:59.817Z" } }, "ocf": { "st": { "value": "1970-01-01T00:00:34Z", "timestamp": "2024-03-28T14:33:58.382Z" }, "mndt": { "value": "2023-01-01", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnfv": { "value": "SAT-iMX8M23WWC-1004.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnhw": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "di": { "value": "36dcc95d-74b4-0b94-b397-7e6c6bb931c9", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnsl": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "dmv": { "value": "res.1.1.0,sh.1.1.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "n": { "value": "Q-Series Soundbar", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnmo": { "value": "HW-Q990C", "timestamp": "2024-03-28T14:33:58.382Z" }, "vid": { "value": "VD-NetworkAudio-002S", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnmn": { "value": "Samsung Electronics", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnml": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnpv": { "value": "7.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnos": { "value": "Tizen", "timestamp": "2024-03-28T14:33:58.382Z" }, "pi": { "value": "36dcc95d-74b4-0b94-b397-7e6c6bb931c9", "timestamp": "2024-03-28T14:33:58.382Z" }, "icv": { "value": "core.1.1.0", "timestamp": "2024-03-28T14:33:58.382Z" } }, "samsungvd.audioSoundFrom": {}, "audioMute": { "mute": { "value": "unmuted", "timestamp": "2024-03-28T16:00:00.010Z" } }, "samsungvd.thingStatus": { "updatedTime": { "value": 1711692427, "timestamp": "2024-03-29T06:07:06.938Z" }, "status": { "value": "Idle", "timestamp": "2024-03-28T14:33:58.409Z" } }, "audioTrackData": { "totalTime": { "value": 0, "timestamp": "2024-03-28T14:34:00.521Z" }, "audioTrackData": { "value": { "title": "", "artist": "", "album": "" }, "timestamp": "2024-03-28T14:34:00.521Z" }, "elapsedTime": { "value": 0, "timestamp": "2024-03-28T14:33:58.913Z" } } } ```
Second HTTP POST call (/devices/{deviceId}/commands)
POST Request: https://api.smartthings.com/v1/devices/{deviceId}/commands
```json { "commands": [ { "component": "main", "capability": execute, "command": execute, "arguments": [ "/sec/networkaudio/eq" ] } ] } ```
Response: ```json { "results": [ { "id": "25f8d805-df95-4b5e-8b62-c253aeb97e62", "status": "COMPLETED" } ] } ```
Third HTTP GET call (/devices/{deviceId}/components/main/status)
GET Request: https://api.smartthings.com/v1/devices/{deviceId}/components/main/status

Response: ```json { "mediaPlayback": { "supportedPlaybackCommands": { "value": [ "play", "pause", "stop" ], "timestamp": "2024-03-28T14:33:58.913Z" }, "playbackStatus": { "value": "stopped", "timestamp": "2024-03-28T14:33:58.913Z" } }, "samsungvd.soundFrom": { "mode": { "value": 1, "timestamp": "2024-03-28T17:23:52.738Z" }, "detailName": { "value": "External Device", "timestamp": "2024-03-28T14:41:14.844Z" } }, "audioVolume": { "volume": { "value": 28, "unit": "%", "timestamp": "2024-03-28T18:05:37.725Z" } }, "samsungvd.deviceInfoPrivate": {}, "mediaInputSource": { "supportedInputSources": { "value": [ "digital", "HDMI1", "bluetooth", "wifi", "HDMI2" ], "timestamp": "2024-03-28T14:33:58.512Z" }, "inputSource": { "value": "digital", "timestamp": "2024-03-28T16:00:05.902Z" } }, "samsungvd.audioPlayback": {}, "refresh": {}, "audioNotification": {}, "execute": { "data": { "value": null } }, "samsungvd.audioInputSource": { "supportedInputSources": { "value": [ "digital", "HDMI1", "bluetooth", "wifi", "HDMI2" ], "timestamp": "2024-03-28T14:33:58.512Z" }, "inputSource": { "value": "digital", "timestamp": "2024-03-28T16:00:05.902Z" } }, "switch": { "switch": { "value": "on", "timestamp": "2024-03-28T15:59:59.817Z" } }, "ocf": { "st": { "value": "1970-01-01T00:00:34Z", "timestamp": "2024-03-28T14:33:58.382Z" }, "mndt": { "value": "2023-01-01", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnfv": { "value": "SAT-iMX8M23WWC-1004.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnhw": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "di": { "value": "36dcc95d-74b4-0b94-b397-7e6c6bb931c9", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnsl": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "dmv": { "value": "res.1.1.0,sh.1.1.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "n": { "value": "Q-Series Soundbar", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnmo": { "value": "HW-Q990C", "timestamp": "2024-03-28T14:33:58.382Z" }, "vid": { "value": "VD-NetworkAudio-002S", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnmn": { "value": "Samsung Electronics", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnml": { "value": "", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnpv": { "value": "7.0", "timestamp": "2024-03-28T14:33:58.382Z" }, "mnos": { "value": "Tizen", "timestamp": "2024-03-28T14:33:58.382Z" }, "pi": { "value": "36dcc95d-74b4-0b94-b397-7e6c6bb931c9", "timestamp": "2024-03-28T14:33:58.382Z" }, "icv": { "value": "core.1.1.0", "timestamp": "2024-03-28T14:33:58.382Z" } }, "samsungvd.audioSoundFrom": {}, "audioMute": { "mute": { "value": "unmuted", "timestamp": "2024-03-28T16:00:00.010Z" } }, "samsungvd.thingStatus": { "updatedTime": { "value": 1711692427, "timestamp": "2024-03-29T06:07:06.938Z" }, "status": { "value": "Idle", "timestamp": "2024-03-28T14:33:58.409Z" } }, "audioTrackData": { "totalTime": { "value": 0, "timestamp": "2024-03-28T14:34:00.521Z" }, "audioTrackData": { "value": { "title": "", "artist": "", "album": "" }, "timestamp": "2024-03-28T14:34:00.521Z" }, "elapsedTime": { "value": 0, "timestamp": "2024-03-28T14:33:58.913Z" } } } ```

So, it appears that the execute section is not being populated correctly:

    "execute": {
        "data": {
            "value": null
        }
Fourth HTTP GET call (/devices/{deviceId}/components/main/capabilities/execute/status)
GET Request: https://api.smartthings.com/v1/devices/{deviceId}/components/main/capabilities/execute/status

Response: ```json { "data": { "value": null } } ```

And similarly, with the last call:

    "execute": {
        "data": {
            "value": null
        }

So, I'm now beginning to suspect that my soundbar itself is messed up. And maybe not a hardware issue, per se, but software / firmware (which cannot be re-flashed). This is based on the following facts:

  1. I have 2 other identical soundbars that don't have this issue.
  2. All 3 soundbars are on the same firmware version (1004).
  3. I've tried to delete and then re-add the Living Room soundbar to SmartThings.
  4. Samsung doesn't allow firmware to be downgraded and also the soundbar won't let me re-install the same firmware from USB if it's already at the same version. This may have possibly corrected the issue.
  5. Nobody else is having this issue.

I'm going to try something drastic. I'm still in my return period for this soundbar. I'm going to re-purchase an identical unit and see what happens.

What do you think?

samuelspagl commented 5 months ago

Hmmn difficult question. I would first of all try, the same set of requests with another soundbar of yours which should (stated on the theory and on the proof that the other ones work quite fine) give different results.

If thats true then I would probably return it πŸ˜…

Dumb question, can you change the eq and "extra capabilites" from the smart things app in the failing soundbar?

royf007 commented 5 months ago

So I tried the same set of API requests on the other 2 soundbars, and the EQ settings are returned correctly in the responses.

Also, in the SmartThings app, I can change the "eq" and "extra capability" settings for all 3 soundbars (including the failing one). Another observation is that the API response returns some sound programs, i.e. "NONE", "POP", "JAZZ", "CLASSIC", but there is no way to set these in the SmartThings app on these soundbars.

Extra Capabilities API Response ```json { "data": { "value": { "payload": { "rt": [ "x.com.samsung.networkaudio.eq" ], "if": [ "oic.if.rw", "oic.if.baseline" ], "x.com.samsung.networkaudio.supportedList": [ "NONE", "POP", "JAZZ", "CLASSIC" ], "x.com.samsung.networkaudio.EQname": "NONE", "x.com.samsung.networkaudio.action": "setEQmode", "x.com.samsung.networkaudio.EQband": [ "0", "0", "0", "0", "0", "0", "0" ] } }, "data": { "href": "/sec/networkaudio/eq" }, "timestamp": "2024-03-26T09:15:00.030Z" } } ```
SmartThings App Screenshots for Living Room Soundbar ![IMG_3992](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/e016be6b-4739-4fec-b26b-3b063ce1d9a8) ![IMG_3990](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/7031c0a4-0a53-46b0-be22-178f95b02f7d) ![IMG_3991](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/444da3bb-5613-4deb-a982-d53ee77bb7ef) ![IMG_3993](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/b666bb07-c9ba-4178-81a5-891c2f585067) ![IMG_3987](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/6feb2d03-7f54-477b-8ce5-0694352cb574) ![IMG_3988](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/02679c4a-aaaf-4034-ac31-ca925edd6079)

I will let you know what happens with the new soundbar! πŸ™‚

samuelspagl commented 5 months ago

sound programs, i.e. "NONE", "POP", "JAZZ", "CLASSIC",

these are eq presets that you can set when your soundmode is set in Standard I think ;)

royf007 commented 5 months ago

Interesting. So, I finally found the eq preset options in the SmartThings app, but the API calls we are currently using don't show the current eq preset, and then setting the preset it in the Samsung Soundbar integration has no effect (not changing in the SmartThings app).

Not a big deal, as I'm sure there may be some other API calls / commands get and set the current eq preset.

Screenshot of EQ Settings in SmartThings App ![IMG_3995](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/3ce9877f-1e5a-41e9-a041-d061c0abe64e)
samuelspagl commented 5 months ago

funny, I think it worked for me tho, when I implemented, but yeah, I also am not really using this feature :D The other things like, bassmode, nightmode etc. are more important ^^

Yeah the SmartThings API in itself is interesting, and also not that clear most of the time (from my point of view)

royf007 commented 5 months ago

So, you're not going to believe this. I just installed a brand-new Q990C and it behaves the same way as the previous Living Room soundbar, i.e. no eq info returned from the API.

It makes me think that Samsung may have changed the behavior of their API, and new device registrations may start to behave the same way. I don't really feel like resetting the other 2 working soundbars to test this theory.

I'll be curious if anyone else reports this issue going forward. So, that being said, can the code be update to "ignore" the empty payload from the eq settings, so other functions can be used?

samuelspagl commented 5 months ago

Interesting πŸ˜….

I'd really love to fiddle around with your soundbars because it is incredibly fascinating.

But that's another topic. Ehmn yeah so the solution for another open issue is to reimplement the configuration process of the soundbar in a way where you can select the specific extra capabilities your soundbar supports and the integration adjusts itself based on that.

Coinficient commented 5 months ago

Hi, just made an account to also confirm this annoying issue, I've done the same steps as @royf007 I have a Q950A Samsung, previously it did slightly work for EQ but I had an overlap of integrations, I am now only able to get Source and Volume and the other non needed info, previously I had access to EQ and Sound Mode, I also do not get the status of advanced features either but I can send for example a command for it, I've done at least 3 resets even deleted the SmartThings app, I've tried to do an firmware upgrade using an USB in the hope it would reset the soundbar but it won't do that unless it's an actual update, I've also tried to remove my device profile since according to Samsung OCF devices have the "API Commands stored locally" the only thing I could try is to add a "capability" but I am not really familiar with the exact payload I should use, quite annoying I must say.

Please do note that before I've engaged into this "experimental" adventure my soundbar just simply stopped returned status for sound mode and advanced features and I thought it's just a SmartThings moment but it wasn't, so from this I can either assume Samsung did a Smart Opsie and messed up the OCF profile or me and @royf007 clearly we have no idea what we're doing, the only option I see here is to add an capability.

samuelspagl commented 5 months ago

So @royf007 and @Coinficient, I can confirm the behaviour...

And honestly it drives me crazy because the obvious issue is that Samsung changed some things in the SmartThings API seemingly quite recently.

Can you both please write the more or less exact dates when it you setup your first devices?

samuelspagl commented 5 months ago

Therefore I am honestly currently not quite sure how to tackle this.

So interestingly, once the integration is setup and populated with a set of for example "Sound Modes" I can still change Soundmodes with the integration. The "only" thing that failes is the update process of these "extra capabilities". And thats the main issue there.

I took a look at the official Changelog, but am not seeing anything that would explain why it is broken.

https://developer.smartthings.com/docs/getting-started/release-notes

Coinficient commented 5 months ago

@samuelspagl That's interesting, well upon some "long shot" inspection I can't 100% confirm my issue started on 26th but it was around that time, but it seems that the case is confirmed how a potential corruption could've happened, the soundbar does connect to an EC2 server, on the same date AWS had an small outage as you can see here, man that's like the stars aligned to mess up the soundbar πŸ˜‚

https://health.aws.amazon.com/health/status?eventID=arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_19EDD_8784715220E

royf007 commented 5 months ago

@samuelspagl , I installed the new soundbar on on 3/25/2024, and probably tried to setup the integration on the same day or the next day. It's unfortunate that Samsung changed their API. I haven't found a way yet through the API to get to the extra capabilities, i.e. subwoofer volume, etc.

Coinficient commented 5 months ago

@samuelspagl I can't give you an exact date when I setup my soundbar but I think it was a year ago, so I've had my soundbar for some time now, on Home Assistant, but I can confirm to you that Woofer, EQ, Sound Mode and all of that we're working it was just a clash of integrations (or so I thought) because I was not getting the exact status but I was able to send commands, including the Woofer which I previously could not because only your integration offers that.

royf007 commented 5 months ago

@samuelspagl , also the other 2 soundbars that are working were setup sometime in December 2023, and then in Home Assistant around February, 2024.

Coinficient commented 5 months ago

We might have to try to add a capability over the API because in the documentation we can do that, I just don't know what payload to use or how the capability looks in the JSON format to add it, because I don't think even Samsung themsevls can help here since OCF devices are a bit different they are like a hybrid.

Coinficient commented 5 months ago

But what is interestingly enough is that @royf007 has the 3rd soundbar "corrupted" profile device in the same manner as I do, including the inability to see the sound mode which I can confirm 100% that I was using this daily before, until one day around March 26th tha I stopped receiving the status for it, this was before I setup your integration, I thought the previous integration since it stopped recveing updates somehow "something happened"

Coinficient commented 5 months ago

I've noticed another user in another open issue I bet has the same problem as us, this is some Smart fishy going on here and I think that AWS API outage had to do something with it, but I can't support this theory without more information.

Coinficient commented 5 months ago

@royf007 if you do not mind, would you share some screenshots from my.smarrthings.com/advanced especially on the "execute" capability so I can at least see what we should've seen there? and what other potential info we might not see? here's how mine looks

https://my.smartthings.com/advanced/

Screenshot 2024-04-01 161854 Screenshot 2024-04-01 162023

royf007 commented 5 months ago

Sure @Coinficient. Interesting, on the Living Room soundbar, the "execute" capability is empty, like yours.

Gym Soundbar - Working ![image](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/d3e2f108-0535-47c0-a166-d47c849e90c0)
Living Soundbar - Missing "Execute" Capabilities ![image](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/444b8f78-c192-4fa0-9c5a-74b9e95b5fb7)

The other interesting observation is that the way Samsung names the soundbars has changed. For the new Living Room soundbar (the one with missing capabilities, the "device name" and "device label" is what I named it. For the other 2 that are working, the "device name" is "Q-Series Soundbar". I don't think it has anything to do with the missing "extra capabilities", but does indicate some changes on the Samsung side.

Device Name Differences ![image](https://github.com/samuelspagl/ha_samsung_soundbar/assets/4976402/22e0a3de-d5c9-4c11-956b-b0a88bb6c3ef)

Let me know if you need anything else.

samuelspagl commented 5 months ago

@samuelspagl That's interesting, well upon some "long shot" inspection I can't 100% confirm my issue started on 26th but it was around that time, but it seems that the case is confirmed how a potential corruption could've happened, the soundbar does connect to an EC2 server, on the same date AWS had an small outage as you can see here, man that's like the stars aligned to mess up the soundbar πŸ˜‚

https://health.aws.amazon.com/health/status?eventID=arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_19EDD_8784715220E

Hmn interesting.

Sure @Coinficient. Interesting, on the Living Room soundbar, the "execute" capability is empty, like yours.

Mine isn't and also doesn't change at all. It still displays the eq settings from when it was set to display it there. I see that your first Soundbar is also displaying the eq

samuelspagl commented 5 months ago

We might have to try to add a capability over the API because in the documentation we can do that, I just don't know what payload to use or how the capability looks in the JSON format to add it, because I don't think even Samsung themsevls can help here since OCF devices are a bit different they are like a hybrid.

If you want to see how the extra capabilities look like, then you can take a look at my documentation website. https://ha-samsung-soundbar.vercel.app/smartthings-api/extra_information

samuelspagl commented 5 months ago

I also just opened an entry in the SmartThings forum. Not sure if anyone will read this, but still I kinda have to try πŸ˜….

https://community.smartthings.com/t/bug-retrieve-custom-capabilities-files/280486

Edit: Also created a support request on their samsung developers site.

Coinficient commented 5 months ago

@royf007 That small name indication is very good observation, for example I have cleared my smartthings app, deleted my soundbar from it, when I open the smartthings app without logging in, it shows up my soundbar to connect it, the name I previously used as if the settings are saved on the soundbar as I thought it would, that means there's something corrupted on the OCF profile and I am not sure if it's related to my samsung account or not, I will try to create a new samsung account and connect my soundbar.

PS Another interesting observation I've noticed is that on my Samsung account it shows up "My TV" is connected not my soundbar I think on samsung servers my soundbar is being seen as a TV another indication of a potential corruption.

https://v3.account.samsung.com/dashboard/devices

Prolly this is the chip board the soundbar uses, unrelated but I will keep looking

https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors/i-mx-8m-family-armcortex-a53-cortex-m4-audio-voice-video:i.MX8M

samuelspagl commented 5 months ago

So I can probably say the not exact but pretty exact time that it stopped working for me πŸ˜… This is from my online SmartThings Dashboard:

Bildschirmfoto 2024-04-01 um 19 15 29

And I took a look at the screenshots of @royf007:

Bildschirmfoto 2024-04-01 um 19 14 34

Both stopped working on the 26th πŸ˜… nice. Basically, the "update" process of the execute API could not write the result of its query in its status ever since πŸ˜…

In which timezone are you?

Coinficient commented 5 months ago

I'm in UK time zone, I wish I actually took a look at that but I kept deleting and adding I thought it was just another SmartThings issue never really did bother to look it up to this extent, but it looks like the theory is almost confirmed

Coinficient commented 5 months ago

I am curious, can any of you connect your soundbar to Alexa? Not that I use it but I did use it previously on Home Assistant to make TTS Announcements easier without the use of an external device, now when I try to login I just don't get anything.

samuelspagl commented 5 months ago

I'm in UK time zone, I wish I actually took a look at that but I kept deleting and adding I thought it was just another SmartThings issue never really did bother to look it up to this extent, but it looks like the theory is almost confirmed

Did you completely remove it from your SmartThings Account? If you just removed it from HomeAssistant it should still be visible.

I am curious, can any of you connect your soundbar to Alexa? Not that I use it but I did use it previously on Home Assistant to make TTS Announcements easier without the use of an external device, now when I try to login I just don't get anything.

Nope πŸ˜… sorry. I'd love to get TTS also working in this integration at some point ^^

Coinficient commented 5 months ago

I've done full sweep, API Tokens, SmartThings, HA, my phone, so yeah if there was a trace it's gone, now 10 mins ago I even "deleted" my SmartThings account or data not sure to what extent Samsung does, but one thing is clear SmartThings consistently has the exact same capabilities as before but the API doesn't, I did a PCAP to see where the app connects and it's a mix of AWS, API and Samsung cloud connect. Domains such as these

ocfconnect-shard-eu02-euwest1.samsungiotcloud.com client.smartthings.com api.smartthings.com

but interestingly enough when I try to login to Amazon Alexa I get errors on api.smartthings.com which indicates that this is Samsung being sneaky, the OCF profile I believe is meant to slow down these issues as if, something doesn't work on the server right now you won't "feel" it right away it will be gradual, but I think someone really "fixed" the API too much πŸ˜‚

While I cannot decrypt the payloads it's most likely to a CA certificate I am not sure as it doesn't really let me decrypt them.

As for the Soundbar it directly connects and only stays connected to AWS

ec2-52-210-126-103.eu-west-1.compute.amazonaws.com

samuelspagl commented 5 months ago

I had some time this evening and created a new configuration setup and reconfigure steps, to enable / disable the custom capabilities. Pull Request: #28

https://github.com/samuelspagl/ha_samsung_soundbar/releases/tag/0.4.0b1

This is very raw and needs to be refactored quite a bit, but it should work.

royf007 commented 5 months ago

I'm in UK time zone, I wish I actually took a look at that but I kept deleting and adding I thought it was just another SmartThings issue never really did bother to look it up to this extent, but it looks like the theory is almost confirmed

Did you completely remove it from your SmartThings Account? If you just removed it from HomeAssistant it should still be visible.

I am curious, can any of you connect your soundbar to Alexa? Not that I use it but I did use it previously on Home Assistant to make TTS Announcements easier without the use of an external device, now when I try to login I just don't get anything.

Nope πŸ˜… sorry. I'd love to get TTS also working in this integration at some point ^^

@samuelspagl , thanks for documenting the extra capabilities API commands on your site, and also for opening the issue on the SmartThings forum.

For Alexa, I've had no issues with getting Alexa to work when removing / adding back the soundbars (even with this current API issue). After setting up the soundbar in SmartThings, I usually have to delete the previous device in Alexa (even if it has the same name as the recently added one), and then in the SmartThings app, go into the soundbar and set it up again in the "Voice Assistant Settings", then do an "Alexa, discover devices" (if necessary).

So regarding TTS, it currently doesn't work from Home Assistant on these soundbars, since they use AirPlay 2, and the current Apple TV integration has a bug. With the Home Assistant Apple TV integration, the soundbar needs to be on the same network as Home Assistant, and then it shows as an Apple TV media player. When you go to do TTS from Home Assistant, it will appear as if the TTS is playing (via AirPlay on the soundbar), but no actual sound comes out. Please see: https://github.com/postlund/pyatv/issues/2351 . I'm waiting for this issue to be resolved.

In the meantime, for TTS from Home Assistant on the Samsung Soundbars, I'm currently using an external device, the WiiM Mini (https://a.co/d/3vjDAxQ) connected to the soundbar via the digital optical input (SPDIF). The catch with the Samsung soundbars is that if you have a TV connected to the HDMI1 (eArc) port, then you cannot select the DIN (optical input) on the soundbar, as the soundbar automatically switches back to HDMI1. My workaround (via an automation, is to turn off the TV prior to announcements, switch the input to DIN on the soundbar, set the volume as needed, make the announcement, and then restore the volume, and turn on the TV (if it was previously on). It's a royal pain. Two of my soundbars do not have a TV connected to them, so I'm using them for pure music, and leave the input setting on DIN (optical).

When the AirPlay issue gets resolved, we should be able to use TTS from the Apple TV integration to do TTS announcements.

Looking forward to your code updates!

royf007 commented 5 months ago

I had some time this evening and created a new configuration setup and reconfigure steps, to enable / disable the custom capabilities.

Pull Request: #28

https://github.com/samuelspagl/ha_samsung_soundbar/releases/tag/0.4.0b1

This is very raw and needs to be refactored quite a bit, but it should work.

@samuelspagl I tried your new alpha release and I was able to add the Living Room soundbar minus the EQ configuration.

Thank you!

samuelspagl commented 5 months ago

I had some time this evening and created a new configuration setup and reconfigure steps, to enable / disable the custom capabilities. Pull Request: #28 https://github.com/samuelspagl/ha_samsung_soundbar/releases/tag/0.4.0b1 This is very raw and needs to be refactored quite a bit, but it should work.

@samuelspagl I tried your new alpha release and I was able to add the Living Room soundbar minus the EQ configuration.

Thank you!

But is the "soundmode" select entity showing anything? I think it should also be empty and trigger some errors.

So while this this issue is unresolved I thought about creating services for each of those "custom capabilities", because changing the value is still possible, but retrieving it isn't. Therefore I'm thinking about adding some more settings to the reconfiguration part, that lets you enable / disable a service for a custom capability despite the entities (and therefore the update process) being disabled.

traqnski89 commented 5 months ago

following up on issue #27 I was able to add my Q800A, but without enabling 'Advanced Audio Switches', 'EQ Selector' and 'Soundmode sector'... Unfortunately, I use mostly the Soundmode selector and Advanced Audio Switches in my automations. I hope you will find a solution soon!

samuelspagl commented 5 months ago

I use mostly the Soundmode selector and Advanced Audio Switches in my automations.

The same goes for me. If I have some free time in the evening, I would create a workaround for these. The workaround would be either:

  1. Enable the entities but disable the update process
  2. Create services that one can call to change the value of one of these "custom capabilities"

What would you prefer? I think the second option is a bit cleaner, even tho it will still leave broken automations.

I do not plan to remove any of the current functionality, but still hope that Samsung will sort these things out.

Coinficient commented 5 months ago

@samuelspagl Just do add some more info, commands for advanced capabilities and sound mode do work, but you cannot get the status for them at least for now, I am not quite sure how best you can tackle this issue as I am not sure how many are affected by this issue, for now it seems isolated although there may be others like me who don't actively engage in github.

samuelspagl commented 5 months ago

Just do add some more info, commands for advanced capabilities and sound mode do work, but you cannot get the status for them at least for now,

Yeah I know thats what I was already stating being the current state with my Soundbar. Thanks for confirming it.

I am currently waiting for Samsungs reply (hopefully they do reply), and will try to implement services for the integration the next days.

Coinficient commented 5 months ago

@samuelspagl Sorry I must've word skipped πŸ˜‚, you can also add the Woofer commands as well, they do work too and I was quite surprised how you managed to get it working, but that is the same no states, as for the EQ I didnt' get a chance to properly test them but I reckon they might be on the same case, quite a shame SmartThings didn't reply yet.

Keep up the good work, you're doing justice to our soundbars πŸ˜‚

samuelspagl commented 5 months ago

Hi @royf007,

If it would be fine with you, I would adjust your ticket description a bit, so that new users can read the details of the current issue without reading the whole thread. :)