Cal, thanks for the assist. The message indicates that the code is working (it returns an error event from the method. This may be due to the TV mode (i.e., you use volume while using the soundbar).
Which key code did you try this with? It looks like code that translated to code 1005 which is reserved. Did you try others? Particularly KEY_TOOLS, KEY_SOURCE, or KEY_SOURCE that work regardless of external source or sound sink.
Results w a 2014(?) Samsung TV dev:21312020-10-11 09:15:06.748 am debugwebSocketStatus: status: closing
dev:21312020-10-11 09:15:01.695 am infoparse: {"event":"ms.error","data":{"message":"unrecognized method value : ms.remote.control"}}
dev:21312020-10-11 09:15:01.360 am infoparse: {"event":"ms.channel.connect","data":{"id":"bf7cd270-2327-11b2-9f26-31ddfd4a529d","clients":[{"id":"bf7cd270-2327-11b2-9f26-31ddfd4a529d","connectTime":586551576,"attributes":{},"isHost":false}]}}
dev:21312020-10-11 09:15:01.345 am debugwebSocketStatus: status: open
dev:21312020-10-11 09:15:01.048 am tracesendCmd: {"method":"ms.remote.control","params":{"Cmd":"Click","DataOfCmd":"KEY_MUTE","Option":"false","TypeOfRemote":"SendRemoteKey"}}, 192.168.1.153
dev:21312020-10-11 09:15:01.044 am tracetest: KEY_MUTE
I was doing some reading on some other forums, and it seems like you can connect over websocket, but first you have to obtain the Name of the TV convert to Base64, connect and obtain the token for future connection. This is far as I could get.
"Token":"12345678" <-8 Character Token will be displayed in the output
Now, you can connect to the TV securely using the Token by going to: wscat -n -c https://TVIPADDRESS:8002/api/v2/channels/samsung.remote.control?token=<8 digit token> and issue commands. By using the token in the URL, the TV will no longer prompt you to accept the remote device connection each time you send a command.
All of the remote control commands can be now sent, and they all work on the TV if they are in the format below
Several things.
Control you is how I control my Samsung Wifi Speakers. Quite simple, so can do. Your Step 3: We will have to capture name and uri. Yours uses 8002 as the final port, mine 8001. Step 6: Base 64: name.encodeAsBase64().toString()
Step 9: Just a parameter to catch
Step 10: Easy
So, yes. What you want should be able to be done. Let me update my test driver some to capture the various data.
Cal,
I created a test driver (no polish, not final version). Tested all but getting token and sending key (but coded those functions.
Step 1: GetData (gets the name of the TV
Step 2: Get token
Step 3: Send Key with key name entry.
I am very interested in what the output for a Send Key is. That should be an event and I want to know if it reports volume for KEY_VOLDOWN.
If this works, I will code further with agreed keys; including the Samsung recommended minimum keys.
Updated code at same site to fix one error found this am. Also, now working on port 8002 only. Added commands for key (no longer need to enter) and updated logging.
Close device
Replace code
Open device
Get Data
Get Token
Menu
At some point, you may need to allow the device on your TV. I have seen this on my UPnP efforts where I can control volume, mute, source, play, pause and etc. I actually plan to include these on the final update (particularly calling the explicit source and volume).
This is great with the latest code now under preferences showing the TV Name, Base64 Name and placeholder for Token.
I did another test today while the TV had gone into deep sleep overnight. TV does not accept connections while it's been off for a while.
However, installed Boot Me Up Scottie Wake on LAN app with a virtual switch. TV wakes right away and then you can start sending commands to it. TV is connected to WiFi and not a wired connection.
Also here are the logs using the latest code and then pressing the keys:
Dave
First thank you for your efforts.... dev:21342020-10-12 12:22:14.743 pm infoTV Test || webSocketStatus: failure: Remote host closed connection during handshake
dev:21342020-10-12 12:22:01.412 pm infoTV Test || webSocketStatus: failure: Remote host closed connection during handshake
dev:21342020-10-12 12:22:01.291 pm traceTV Test || getToken: name = W1RWXVNhbXN1bmcgTEVENjU=
dev:21342020-10-12 12:21:56.077 pm traceTV Test || getData: name = [TV]Samsung LED65
Observation: Token appears to be returned, but not used when sending key. There's no field in settings to add token...
Question: why are two ports used ?
Thanks again
I think it might be running into an issue where it can't verify the self-signed certificate on the Samsung TV so it errors out when connecting. I was running into this as well trying to connect directly using wscat.
I see that Hubitat added the ability to ignore SSL warnings in 2.1.8. Maybe add the IgnoreSSLIssues into the paramters section? Common Methods Object - Hubitat Documentation
Token should be added automatically via the driver. It is in the return stream and I am trying to capture. If not captured, then the whole message is parsed so I can correct the software. However, I will update to add manual token entry via a preference (it will update the token field and not be required once I get the data structure correct).
ignoreLocalHost. I will try this variable. It is really for developmental environemnts; however, if it works, then great.
Will play some and provide update in several hours.
Next version available. I have added preferences for port and for token. Uninstall and reInstall. Then GetData to get name and GetToken (starts the real test).
Question: In your playing, have you had your TV ask for access?
You can get the TV's view of approved external control through the Network Multimedia device manager. Path is TOOLS -> Network -> Multimedia Device Manager. When you select the device, you options. Interesting one is View Details and what service is available. Of interest is the Device Name and the Service.
Dave
PS - shopping to replace my 2015 TV with a 2020 Samsung. Will then move faster. Final product will automate the token gathering when you save preferences. - D
It is slow. Mine is 2015 model. Will get my 2020 model on Saturday - so real fun begins Sunday. Looking for suggestions on desired controls. I want to include both remote and UPNP controls (UPNP can provide explicit volume and source control that may be useful). Looking for a Wake On Lan implementation to integrate also - but that is after I get my new TV.