Closed tjipke closed 2 years ago
samsungtv documentation samsungtv source (message by IssueLinks)
Hey there @chemelli74, @epenet, mind taking a look at this issue as it has been labeled with an integration (samsungtv
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
Could you please upload your integration diagnostics?
2022.4 added support for encrypted websocket (J/K models) but maybe yours works better with the newer websocket protocol.
cc @bdraco
Could you please upload your integration diagnostics?
2022.4 added support for encrypted websocket (J/K models) but maybe yours works better with the newer websocket protocol.
cc @bdraco
I uploaded it, it is above: config_entry-samsungtv-ff588055230ee3b951b123e81d302983.json.txt. Or is that not what you meant?
Can you try removing the attempt to connect to the encrypted bridge in: https://github.com/home-assistant/core/blob/24b7d1f47b19ea7700a266a8245b85b190a6b4cf/homeassistant/components/samsungtv/bridge.py#L96-L113
So that you only have:
if info := await bridge.async_device_info():
return RESULT_SUCCESS, port, METHOD_WEBSOCKET, info
Then see if it is better and you regain control of your TV.
Hi, I tried it, but it did not help.
FWIW, I picked up the latest source code of HA, did a checkout of version 2022.4.7, copied the samsungtv into custom_components, got an error that a version was missing, added the version to the manifest and got samsungtv 'running' as custom component. Then did the change in your bridge.py (rebooted HA), but it did not work (setting e.g. volume did work) Then readded the logging on line 97 (but turned it into a warning, and changed it to say skipping checking for encrypted), and it did show up in the logging (twice?!). I don't thing there is anything privacy related in it, so here is that logging, maybe it is of any help?
2022-04-26 20:28:11 WARNING (MainThread) [custom_components.samsungtv] Fetching rest info via 8002 was successful: {'id': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'name': '[TV] Living room', 'version': '2.1.0', 'device': {'type': 'Samsung SmartTV', 'duid': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'model': '16_HAWKM_FHD', 'modelName': 'UE32K5600', 'description': 'Samsung DTV RCR', 'networkType': 'wireless', 'ssid': '50:d2:f5:ea:fe:95', 'ip': '192.168.7.208', 'firmwareVersion': 'Unknown', 'name': '[TV] Living room', 'id': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'udn': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'resolution': '1920x1080', 'countryCode': 'NL', 'msfVersion': '2.1.0', 'smartHubAgreement': 'true', 'VoiceSupport': 'false', 'GamePadSupport': 'true', 'wifiMac': 'F8:77:B8:BB:98:35', 'developerMode': '0', 'developerIP': '', 'OS': 'Tizen'}, 'type': 'Samsung SmartTV', 'uri': 'https://192.168.7.208:8002/api/v2/', 'remote': '1.0', 'isSupport': '{"remote_available":"true","remote_fourDirections":"true","remote_touchPad":"true","remote_voiceControl":"false","DMP_available":"true","DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","EDEN_available":"true"}'}, skip checking for encrypted
2022-04-26 20:28:11 WARNING (MainThread) [custom_components.samsungtv] Fetching rest info via 8002 was successful: {'id': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'name': '[TV] Living room', 'version': '2.1.0', 'device': {'type': 'Samsung SmartTV', 'duid': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'model': '16_HAWKM_FHD', 'modelName': 'UE32K5600', 'description': 'Samsung DTV RCR', 'networkType': 'wireless', 'ssid': '50:d2:f5:ea:fe:95', 'ip': '192.168.7.208', 'firmwareVersion': 'Unknown', 'name': '[TV] Living room', 'id': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'udn': 'uuid:41232434-2995-4e0d-96b7-5393f96ec376', 'resolution': '1920x1080', 'countryCode': 'NL', 'msfVersion': '2.1.0', 'smartHubAgreement': 'true', 'VoiceSupport': 'false', 'GamePadSupport': 'true', 'wifiMac': 'F8:77:B8:BB:98:35', 'developerMode': '0', 'developerIP': '', 'OS': 'Tizen'}, 'type': 'Samsung SmartTV', 'uri': 'https://192.168.7.208:8002/api/v2/', 'remote': '1.0', 'isSupport': '{"remote_available":"true","remote_fourDirections":"true","remote_touchPad":"true","remote_voiceControl":"false","DMP_available":"true","DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","EDEN_available":"true"}'}, skip checking for encrypted
Yes, that's the correct way to test your changes. Please ensure that you enable full logging:
logger:
default: warn
logs:
homeassistant.components.samsungtv: debug
custom_components.samsungtv: debug
samsungtvws: debug
Also, maybe it is easier for testing to adjust line 229 in __init__.py
:
https://github.com/home-assistant/core/blob/2bb42f48aa1dd6768357b39e1262c39115f95534/homeassistant/components/samsungtv/__init__.py#L229
You can replace it with
method: str = "websocket"
@tjipke did it help when you forced it to use method websocket
?
@tjipke did it help when you forced it to use method
websocket
?
@epenet unfortunately not. Just retested it and I see no difference...
This is the logging now:
Aargh. It is still using SamsungTVEncryptedBridge
bridge (encrypted
method), and it is not using the SamsungTVWSBridge
bridge (websocket
method).
Since you only provided partial log, it is hard to see why it is not picking it up.
Sorry for providing only the partial log, but I found the problem in your work arround.
Setting the method to "websocket", won't change anything in the call to _async_get_device_bridge, since it only uses entry.data and updated_data.
So I also added this line:
updated_data[CONF_METHOD]=method
and because of this line in bridge.py (139):
if method == METHOD_ENCRYPTED_WEBSOCKET or port == ENCRYPTED_WEBSOCKET_PORT:
made me wonder if I also should set the port explicitly to: WEBSOCKET_SSL_PORT
so I also did that and added:
updated_data[CONF_PORT]=port
So now it work.
But what is the real problem now? Do I understand it correct that my TV seems to support an encrypted websocket but not for sending POWER OFF?
This is the theory:
legacy
(port 55000)encrypted
(port 8000)websocket
(port 8001/8002)What we discovered through testing is that 2nd generation TVs also have some basic websocket support, but are unable to send commands through it. 3rd generation TVs do not support encrypted
method at all, and only support websocket
. It was therefore decided in #68717 to force encrypted
method if it was supported, and only keep websocket
method if encrypted
method is not supported.
I'll check with @bdraco what the best way to handle that is.
I have just created a PR #71291 Could you please try it using a custom component?
You would need to remove the integration and re-add it, so that it runs the discovery checks in full.
If all goes well, the method will have been set to websocket
in the diagnostics entry, and the commands will be working correctly.
@tjipke the PR has been merged, so could you please try with latest code from dev
branch to confirm it's ok?
@epenet, I tested it, but did it by copying the changed bridge.py
& __init__.py
from your pull request to my version (did not want to upgrade to latest HA yet).
After rebooting and without removing the integration, the power off still worked! (this was the result of the diagnostics:
config_entry-samsungtv-ff588055230ee3b951b123e81d302983.json (2).txt at that time)
Then I removed the integration, restarted HA, and samsungtv was rediscovered, so I configered it. And after that it also still worked!
So it seems your fix did the trick. Thanks for your quick response and fix!
The problem
In previous versions of the samsungtv integration, I could turn my TV off, but since the last version(s) this isn't working anymore. An error shows up in the HA logging:
Unknown power_off command for UE32K5600 (192.168.7.208): sending KEY_POWEROFF and KEY_POWER
What version of Home Assistant Core has the issue?
core-2022.4.7
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
samsungtv
Link to integration documentation on our website
https://www.home-assistant.io/integrations/samsungtv
Diagnostics information
config_entry-samsungtv-ff588055230ee3b951b123e81d302983.json.txt
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
No response