Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing the timeout fix #2

Closed
aseabridge opened this issue Nov 25, 2018 · 196 comments
Closed

Testing the timeout fix #2

aseabridge opened this issue Nov 25, 2018 · 196 comments

Comments

@aseabridge
Copy link

Thanks for putting in a fix for the timeout @kdschlosser. I can see you’ve added the LG logging to the file. To test this with my 2017/2018 tv I’m guessing I’ll need to checkout this timeout branch and call the method. What command should I issue? When I tried using this library earlier today diectlty it was giving me errors about bytes so I’m guessing I was missing some parameters.

@eclair4151
Copy link
Collaborator

so yea you will need to checkout this branch git checkout --track origin/timeout_fix

then try to run this python command

import samsungctl

config =  {
        "name": "samsungctl",
        "description": "PC",
        "id": "11",
        "host": "YOUR IP",
        "port": 8002,
        "method": "websocket"
    }

with samsungctl.Remote(config) as remote:
    remote.control("KEY_PLAY")

@kdschlosser
Copy link
Owner

tanks @eclair4151

@fluxdigital
Copy link

Thanks. I'm not sure if I'm doing something wrong but I checked out that branch. Then saved the phython above as test.py and then ran it in Thonny. I got the following:

Python 3.5.3 (/usr/bin/python3)
>>> %Run test.py
Traceback (most recent call last):
  File "/home/pi/Documents/Samsungcti-test/test.py", line 12, in <module>
    with samsungctl.Remote(config) as remote:
  File "/home/pi/.local/lib/python3.5/site-packages/samsungctl/remote.py", line 10, in __init__
    self.remote = RemoteWebsocket(config)
  File "/home/pi/.local/lib/python3.5/site-packages/samsungctl/remote_websocket.py", line 22, in __init__
    self._serialize_string(config["name"])), config["timeout"])
KeyError: 'timeout'
>>> 

@kdschlosser
Copy link
Owner

use this instead.

import samsungctl

config =  {
    "name": "samsungctl",
    "description": "PC",
    "id": "11",
    "host": "YOUR IP",
    "port": 8002,
    "method": "websocket",
    "timeout": 5
}

with samsungctl.Remote(config) as remote:
    remote.control("KEY_PLAY")

@fluxdigital
Copy link

Hmm so I checked my tv is on and on the network and ran a scan to check the ip is correct. Then I ran the script above and get this:

>>> %Run test.py
Traceback (most recent call last):
  File "/home/pi/Documents/Samsungcti-test/test.py", line 13, in <module>
    with samsungctl.Remote(config) as remote:
  File "/home/pi/.local/lib/python3.5/site-packages/samsungctl/remote.py", line 10, in __init__
    self.remote = RemoteWebsocket(config)
  File "/home/pi/.local/lib/python3.5/site-packages/samsungctl/remote_websocket.py", line 22, in __init__
    self._serialize_string(config["name"])), config["timeout"])
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_core.py", line 487, in create_connection
    websock.connect(url, **options)
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_core.py", line 214, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_handshake.py", line 69, in handshake
    status, resp = _get_resp_headers(sock)
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_handshake.py", line 127, in _get_resp_headers
    status, resp_headers = read_headers(sock)
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_http.py", line 226, in read_headers
    line = recv_line(sock)
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_socket.py", line 101, in recv_line
    c = recv(sock, 1)
  File "/home/pi/.local/lib/python3.5/site-packages/websocket/_socket.py", line 93, in recv
    "Connection is already closed.")
websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.
>>> 

@DJPsycho82
Copy link

DJPsycho82 commented Nov 26, 2018

I'm struggling a while with samsungctl. I'm pretty new with python and not a programmer for work. But I can read most of the code without problems. I want to help fixing this issue. I own a Samsung TV Q7F 2017 model. I run the 'program' samsungctl on a Raspberry pi. When i run the program i get the following output :

{
"data": {
"id": "5c786543-cfc2-4820-8a4f-d323113c78dc",
"token": "17223081",
"clients": [
{
"attributes": {
"name": "c2Ftc3VuZ2N0bA=="
},
"connectTime": 1543258140926,
"deviceName": "c2Ftc3VuZ2N0bA==",
"id": "5c786543-cfc2-4820-8a4f-d323113c78dc",
"isHost": false
}
]
},
"event": "ms.channel.connect"
}
Error: Permission denied

Looks like there is something going wrong with the Token but i'm not sure how to solve it. What am i doing wrong or could i test some code to fix this?

@DJPsycho82
Copy link

Also nice to know, samsung isn't using smart view for their new tv's. They use smart things now to control the equipment they sell. I only own a TV. But i can check tonight if the smart things app sends some usefull information to the tv. I am not a star with wireshark, but i can try :)

@sebdbr
Copy link

sebdbr commented Nov 27, 2018

Hello !
Before the upgrade to the 1250 firmware, I was able to control my Samsung TV with samsungctl through Domoticz.
Since I've download the new remote_websocket.py file, there isn't error messages anymore when I try a samsungctl command, but I obtain a "permission denied" even if I select "authorise" on my TV.
I guess I have to create a token.txt file somewhere, but I don't know exactly where, and I can't find how to obtain this token... I tried to access to the "wss://@tvip:8002/..." as mentioned sooner with several browser, but I have no response from the TV...
I need some help...
Thanks for reading !

@kdschlosser
Copy link
Owner

I am working on the issue. I do not own a TV to be able to test with. I am going to set up a slack account for this repo. maybe someone would be willing to forward a few ports so I can have access to the TV. it would greatly speed up the development process not having to do the whole back and forth thing.

adding would be so the IP can be sent to me. if there is anyone willing to do this for me let me know. At the same time I will also check remote button press responses and see if i can possibly leverage the TV to give me some other information/control as well. I am pretty sure I can get volume change notifications from the TV. and possibly channel change and input change. But i need to have access to the TV. after initial access I will request a few more ports be forwarded. but the ports I will not know until i connect with the TV

@eclair4151
Copy link
Collaborator

I’m going to do some testing on my M series In about 40 min when I get home from work :)

@kdschlosser
Copy link
Owner

@kdschlosser
Copy link
Owner

@eclair4151 if you will be home in 40 minutes. join that slack chat. we can hash this thing out collectively.

I know that the TV is capable of doing more over that web scoket we simply need to find out what exactly.

I am going to write a version of the code that handles the socket connection differently. I want to keep the connection open in a manner that will allow for all messages to come in from the TV at any time, the websocket library has the ability to do this via the WebSocketApp class.

@kdschlosser
Copy link
Owner

ok so I wanted to let you all know where I am at.

I still have not gotten a full test result as far as the websocket thing goes.

I have however managed to extend the functionality of the package to include.

getting:
    brightness
    contrast
    color temp
    color
    sharpness
    mute
    volume
    channel
    source
    channel info
    channel list
    source list
    media playback position
    media info
    dtv info
    channel list
    current program information
    detail channel information
    detail program information
    extended information about what options the TV has

all of the below are direct input meaning
you will be able to set the volume to 20 or 30 or 50 or whatever you want directly

setting
    brightness
    contrast
    color temp
    color
    sharpness
    mute
    volume
    channel
    source
    media position

My TV is an older one. But I am sure these will all work with a newer TV a guy I know tested a few of them with success.

It is going to be a very large amount of code that has to be added to support all of the above, I can do it in a dynamic nature which on the back end of it I am. But I am going to hard code most of the interface. this way it is IDE compatible and not a complete mystery how to use.

But I bet you will all like to see volume the current volume or channel data in your favorite HA program eh??

Once I am done with it will be up to you to get the authors of those programs to add that functionality. I am keeping the current API in tact so the package will function as it did before. I am just extending onto it.

I have sorted the issues with the discovery process which is a +

@sebdbr
Copy link

sebdbr commented Nov 28, 2018

Breaking news : In fact it seems to work properly if I run it as a sudoer ("sudo samsungctl -i --host xxx.xxx.xxx.xxx --port 8002 --method websocket --timeout 10")... Now it remains to make it work through Domoticz... to be continued.

@sebdbr
Copy link

sebdbr commented Nov 28, 2018

Good news. I'm able again to control the volume through domoticz ... It remains to adapt the keys. For now, I can't turn the tv off. I have a post 2016 ue49mu6105k model ... Do you think I need to edit the interactive.py file?

@DJPsycho82
Copy link

Yesterday my router died, so had something else to do ;) But i'm online again. Can i test the lastest code? Not sure which one to clone though...

@DJPsycho82
Copy link

DJPsycho82 commented Nov 28, 2018

I can confirm though that executing the samsungctl with sudo works! I tried it with the old version, but not yet with the version couple of days ago. After 1 button press it stops working though, have to CTRL+C the program and start it again for the next command. Just figured out that also without the Sudo it works now. Not sure why ....

@kdschlosser
Copy link
Owner

well it is good to know that it is in fact working to some extent. so we know the solution is viable. just have to work out some of the bugs.

I have the back end for the added controls finished up. I am adding the methods at this point.
from what I am gathering you should be able to do things like change the playing content that is on a USB getting playing content meta data. all kinds of things. there are over 100 different things that can be changed/manipulated.

I am looking for that one single things that will tell me what the firmware version is or something to that effect. it will make the selection of using ssl or not much easier. instead of a try and if it fails then do something else routine.

@eclair4151
Copy link
Collaborator

Did you see my comment on slack? I think I have found a good way to detect to use ssl or not

@kdschlosser
Copy link
Owner

I did want to post my progress. I now have a plethora of output from the TV. all kinds of goodies.

track_count: 0
media_duration: 0:00:00
media_uri: None
media_metadata: None
playback_device: NETWORK,NONE
record_device: NOT_IMPLEMENTED
write_status: NOT_IMPLEMENTED
state: NO_MEDIA_PRESENT
status: OK
speed: 1
position_info: {
    'absolute_time': '0:00:00',
    'absolute_count': 2147483647,
    'relative_count': 2147483647,
    'relative_time': '0:00:00',
    'track_uri': None,
    'track_metadata': None,
    'track_duration': '0:00:00',
    'track_number': 0
}
device_capabilities: [
    'NETWORK,NONE',
    'NOT_IMPLEMENTED',
    'NOT_IMPLEMENTED'
]
brightness: 100
contrast: 100
sharpness: 55
color_temperature: 3
protocol_info: {
    'source': None,
    'sink': [
        'http-get:*:image/jpeg:*',
        'http-get:*:audio/mpeg:*',
        'http-get:*:video/x-msvideo:*',
        'http-get:*:video/x-ms-asf:*',
        'http-get:*:video/x-divx:*',
        'http-get:*:video/x-ms-wmv:*',
        'http-get:*:video/x-mkv:*',
        'http-get:*:video/mp4:*',
        'http-get:*:video/x-avi:*',
        'http-get:*:video/avi:*',
        'http-get:*:video/x-flv:*',
        'http-get:*:video/mpeg:*',
        'http-get:*:video/3gpp:*',
        plus 158 more
    ]
}
x_audio_selection: None
x_video_selection: None
banner_information: None
channel_list: {
    'sort': None,
    'satellite_id': None,
    'channel_list_type': '0x02',
    'version': 19,
    'channel_list_url': 'http://192.168.1.64:9090/BinaryBlob/3/ChannelList.dat',
    'supported_channels': []
}
source_list: [
    {
        'is_label_editable': False,
        'is_connected': True,
        'id': 0,
        'viewable': True,
        'name': 'TV'
    },
    {
        'viewable': False,
        'name': 'PC',
        'is_label_editable': True,
        'label': 'PC',
        'is_connected': True,
        'id': 67
    },
    {
        'viewable': False,
        'name': 'DLNA',
        'is_label_editable': False,
        'device_name': 'HDHomeRun DMS 131F777B',
        'is_connected': True,
        'id': 23
    },
    {
        'viewable': True,
        'name': 'HDMI1/DVI',
        'is_label_editable': True,
        'label': 'HDMI1/DVI',
        'is_connected': False,
        'id': 71
    },
    {
        'viewable': True,
        'name': 'HDMI2',
        'is_label_editable': True,
        'label': 'HDMI2',
        'is_connected': False,
        'id': 72
    },
    {
        'viewable': True,
        'name': 'HDMI3',
        'is_label_editable': True,
        'label': 'HDMI3',
        'is_connected': False,
        'id': 73
    },
    {
        'viewable': True,
        'name': 'HDMI4',
        'is_label_editable': True,
        'label': 'HDMI4',
        'is_connected': False,
        'id': 74
    },
    {
        'viewable': False,
        'name': 'AV1',
        'is_label_editable': True,
        'label': 'AV1',
        'is_connected': False,
        'id': 55
    },
    {
        'viewable': False,
        'name': 'AV2',
        'is_label_editable': True,
        'label': 'AV2',
        'is_connected': False,
        'id': 56
    },
    {
        'viewable': True,
        'name': 'COMPONENT',
        'is_label_editable': True,
        'label': 'COMPONENT',
        'is_connected': False,
        'id': 63
    },
    {
        'is_label_editable': False,
        'is_connected': False,
        'id': -1,
        'viewable': False,
        'name': 'USB'
    }
]
source: {
    'is_label_editable': False,
    'is_connected': True,
    'id': 0,
    'viewable': True,
    'name': 'TV'
}
channel: {
    'channel_type': 'CATV',
    'program_number': 0,
    'ptc': 6,
    'major': 6,
    'minor': 0
}
program_information_url: http://192.168.1.64:9090/BinaryBlob/4/CurrentProgInfo.dat
current_time: None
schedule_list_url: http://192.168.1.64:9090/BinaryBlob/0/ScheduleList.dat
watching_information: {
    'information': None,
    'tv_mode': 'Tuner'
}
mute: False
volume: 50
year: 2011
region: USA
tuner_count: 1
dtv_support: True
pvr_support: False

so now we can get notification if anything on the TV changes. woo yah! I am able to set the channel and volume all the things I stated.

@kdschlosser
Copy link
Owner

ok here is the version I have been working on.
if you run the example.py file it will run a series of tests and print out a whole mess of data. if you would be willing to copy and paste that data to me I will be able to make sure that everything is working properly. This is still very experimental. it is going to have some hiccups.

https://github.com/kdschlosser/samsungctl/tree/upnp_features

@sebdbr
Copy link

sebdbr commented Nov 30, 2018

When I try to "git clone" the repositories, I have no UPNP directory, nor example.py file...

@eclair4151
Copy link
Collaborator

Make sure you checkout the correct branch

@fluxdigital
Copy link

Thanks @kdschlosser. I've tried git clone but get an error for some reason. I can git clone the main branch fine but just not this one. not sure why? I uninstalled git and reinstalled it but still no joy. This is the error I get:

pi@raspberrypi:~ $ cd /home/pi/Documents/Samsung-check
pi@raspberrypi:~/Documents/Samsung-check $ git clone https://github.com/kdschlosser/samsungctl/tree/upnp_features
Cloning into 'upnp_features'...
fatal: repository 'https://github.com/kdschlosser/samsungctl/tree/upnp_features/' not found

@fluxdigital
Copy link

Yeah just tried on my laptop too, the above was on my pi. And I get the same issue.

@eclair4151
Copy link
Collaborator

try
git clone https://github.com/kdschlosser/samsungctl.git
git checkout upnp_features

@eclair4151
Copy link
Collaborator

eclair4151 commented Nov 30, 2018

when i run it i get

Traceback (most recent call last):
  File "/Users/tomershemesh/PycharmProjects/samsungctl_branch/samsungctl/example.py", line 41, in <module>
    for tv in remote.discover(5):
  File "/Users/tomershemesh/PycharmProjects/samsungctl_branch/samsungctl/upnp/discover.py", line 146, in discover
    for item in socket.getaddrinfo('', None, socket.AF_INET):
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 743, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

@fluxdigital
Copy link

Still no luck I'm afraid, it can't find the branch:

pi@raspberrypi:~/Documents/Samsung-check $ git clone https://github.com/kdschlosser/samsungctl.git
Cloning into 'samsungctl'...
remote: Enumerating objects: 57, done.
remote: Counting objects: 100% (57/57), done.
remote: Compressing objects: 100% (52/52), done.
remote: Total 483 (delta 21), reused 27 (delta 3), pack-reused 426
Receiving objects: 100% (483/483), 114.06 KiB | 97.00 KiB/s, done.
Resolving deltas: 100% (267/267), done.
pi@raspberrypi:~/Documents/Samsung-check $ git checkout upnp_features
fatal: Not a git repository (or any of the parent directories): .git
pi@raspberrypi:~/Documents/Samsung-check $ sudo git checkout upnp_features
fatal: Not a git repository (or any of the parent directories): .git
pi@raspberrypi:~/Documents/Samsung-check $ 

@fluxdigital
Copy link

Actually looks like I just needed to cd up to the SamsungCtl folder and then switch branch. Ran the discover.py file and get this:

>>> %Run discover.py
Traceback (most recent call last):
  File "/home/pi/Documents/Samsung-check/samsungctl/samsungctl/upnp/discover.py", line 196, in <module>
    for f_device in discover(10):
  File "/home/pi/Documents/Samsung-check/samsungctl/samsungctl/upnp/discover.py", line 146, in discover
    for item in socket.getaddrinfo('', None, socket.AF_INET):
  File "/usr/lib/python3.5/socket.py", line 733, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

@kdschlosser
Copy link
Owner

also try this URL

http://TV IP:8001/api/v2/applications/ExtraService

@Murph24
Copy link

Murph24 commented Dec 23, 2018

http://TV IP:8001/api/v2/applications/ExtraService

Returns:

{"id":"3201512006912","name":"Extra","running":true,"version":"3.172.52","visible":false}

@kdschlosser
Copy link
Owner

is it smartview that is doing the logging or is it the TV?

even if smartview is enabling you to see the logs did you have to enable the developer or debugging mode on the TV??

@kdschlosser
Copy link
Owner

OK I am not sure what the extra thing is. but i am sure we will need it somehow.

@Murph24
Copy link

Murph24 commented Dec 23, 2018

Here are the log events for the extraService call

DEBUG | "IPC callRPC : result : {\"appId\":\"3201512006912\",\"name\":\"Extra\",\"running\":true,\"version\":\"3.172.52\",\"visible\":false}\n" | "timestamp: 1545554068442, file: IpcClient.cpp, func: transceive_cb_ : 190"
-- | -- | --
DEBUG | "## getApplication ##" | "timestamp: 1545554068400, file: TizenDevice.cpp, func: getApplication : 411"
DEBUG | "getApplication called!! id=ExtraService" | "timestamp: 1545554068399, file: ApiV2.cpp, func: RestHandler : 155"
DEBUG | "uri : /api/v2/applications/ExtraService, method: GET"

@kdschlosser
Copy link
Owner

try sending this down the websocket and see what happens

{
	"params": {
		"to": "host", 
		"data": "", 
		"event": "ed.edenApp.get"
	}, 
	"method": "ms.channel.emit"
}

@kdschlosser
Copy link
Owner

also can you change the TV channel from smartview?? if so do it and log it. let me see those logs

Not a channel up or down. a direct input of the channel

@kdschlosser
Copy link
Owner

I believe this is going to be the key for activating the TV's voice control.

I am going to add that to the library. so you folks that have a hard on for all things Alexa (or whatever else is voice controlled) you will be able to tell that thing to have the TV listen for a voice command.

here is the key

KEY_BT_VOICE

@kdschlosser
Copy link
Owner

if someone wants to test that to see if it is in fact for enabling the voice input that would help me a lot

@Murph24
Copy link

Murph24 commented Dec 23, 2018

{
	"params": {
		"to": "host", 
		"data": "", 
		"event": "ed.edenApp.get"
	}, 
	"method": "ms.channel.emit"
}

Returns:

responce_log.txt

@Murph24
Copy link

Murph24 commented Dec 23, 2018

Here is a log for hitting most of the smartview "remote control" commands, including voice input mic:

DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Release\",\"DataOfCmd\":\"KEY_BT_VOICE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555220546, file: RemoteChannel.cpp, func: onSocketMessage : 977"
-- | -- | --
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Release\",\"DataOfCmd\":\"KEY_BT_VOICE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555220540, file: RemoteChannel.cpp, func: onSocketMessage : 977"
INFO | "voice App status changed to hide" | "timestamp: 1545555220540, file: RemoteControl.cpp, func: voiceStatusChanged : 99"
DEBUG | "uri: /remoteControl/voiceStatus/hide method: POST" | "timestamp: 1545555220540, file: RemoteControl.cpp, func: RestHandler : 161"
INFO | "voice App status changed to hide" | "timestamp: 1545555220534, file: RemoteControl.cpp, func: voiceStatusChanged : 99"
DEBUG | "uri: /remoteControl/voiceStatus/hide method: POST" | "timestamp: 1545555220533, file: RemoteControl.cpp, func: RestHandler : 161"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_HOME\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555220451, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_GUIDE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555216554, file: RemoteChannel.cpp, func: onSocketMessage : 977"
INFO | "voice App status changed to standby" | "timestamp: 1545555215724, file: RemoteControl.cpp, func: voiceStatusChanged : 99"
DEBUG | "uri: /remoteControl/voiceStatus/standby method: POST" | "timestamp: 1545555215724, file: RemoteControl.cpp, func: RestHandler : 161"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Release\",\"DataOfCmd\":\"KEY_BT_VOICE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555215412, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Press\",\"DataOfCmd\":\"KEY_BT_VOICE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555215371, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_MUTE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555211534, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_VOLDOWN\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555211052, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_VOLUP\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555210373, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_CHDOWN\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555209125, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Click\",\"DataOfCmd\":\"KEY_CHUP\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555207589, file: RemoteChannel.cpp, func: onSocketMessage : 977"

@kdschlosser
Copy link
Owner

YES!!!!!!

that is what I wanted

I made the data a little easier to read. then you will understand why I wanted to have this data

some_output.txt

@kdschlosser
Copy link
Owner

here are the 2 that are specific for the voice. it is a press and release.

DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Release\",\"DataOfCmd\":\"KEY_BT_VOICE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555215412, file: RemoteChannel.cpp, func: onSocketMessage : 977"
DEBUG | "msg : {\"method\":\"ms.remote.control\",\"params\":{\"Cmd\":\"Press\",\"DataOfCmd\":\"KEY_BT_VOICE\",\"Option\":false,\"TypeOfRemote\":\"SendRemoteKey\"}}\n" | "timestamp: 1545555215371, file: RemoteChannel.cpp, func: onSocketMessage : 977"

Which is cool. because the buttons show a 'Pressed' and a 'Released' which means that you can most likely use the same commands for all buttons on the remote.

Another project that I develop for is superb handling of PC based remote controls / gamming controllers. pretty much any kind of an input device. and how it generates notifications one can use that pressed and released feature to mimic holding a button down.

@kdschlosser
Copy link
Owner

I am wondering what these URI's are

/remoteControl/voiceStatus/standby
/remoteControl/voiceStatus/hide

@kdschlosser
Copy link
Owner

also I am wondering if the query to http://TV IP:8001/api/v2/applications/ExtraService is what lets us know if the TV supports Eden apps. in the log you posted a ways back that URI gets accessed right before the calls using the websocket to ed.edenApp.get

@Murph24
Copy link

Murph24 commented Dec 23, 2018

Not sure.. but when you hit the voice mic button it puts a menu up on the screen and waits for a voice command, so “standby”. Hit the voice button again it hides that menu. The logs seem to confirm this

@kdschlosser
Copy link
Owner

I did want to let you know that if you launch samsungctl from a script and not the command line you can keep the socket connection open to see if there is anything that is sent out the websocket when you do various things on the TV,

if you use this script it will print out debugging message if any messages come in the websocket

import samsungctl
import logging
import threading


logger = logging.getLogger('samsungctl')

logger.setLevel(logging.DEBUG)

config = {
    "name": "samsungctl",
    "description": "PC",
    "id": "",
    "host": "192.168.0.10",
    "port": 8002,
    "method": "websocket",
    "timeout": 0,
}

event = threading.Event()

with samsungctl.Remote(config) as remote:
    try:
        event.wait()
    except KeyboardInterrupt:
        pass

@kdschlosser
Copy link
Owner

at any rate. It is time for me to go and watch some TV and lay down. it is 2:30 AM here. I have only had 4 hours sleep in the last 3 days. I think I am about due to sleep for a solid 8 hours

@dcorsus
Copy link

dcorsus commented Dec 23, 2018

@Murph24
I would think you need to add the meta data to have Netflix start content , seen as in the log. So that would be

{"method":"ms.channel.emit","params":{"data":{"action_type":"DEEP_LINK","appId":"11101200001","checkUpdate":false,"deepLink":"netflix","metaTag":"m=60000901&trackId=254080000&&source_type_payload=groupIndex%3D2%26tileIndex%3D6%26action%3Dmdp%26movieId%3D60000901%26trackId%3D254080000"},"event":"ed.apps.launch","to":"host"}}

I've received the Data:101 response on trying to get the icondata, I suspect is means something like missing information.

So far I have been unsuccessful locating any of the .cpp files involved ... so that will be the task of the day.

@Murph24
Copy link

Murph24 commented Dec 23, 2018

@dcorsus yes I was thinking the same thing but had to quit last night. Just tried this morning and it does in fact work (need to put "checkupdate": false in quotes). Your request above successfully launched The Grinch on netlfix. Response was

2018-12-23 10:21:28 DEBUG (Thread-2) [samsungctl] incoming message: {"data":200,"event":"ed.apps.launch","from":"host"}

@kdschlosser
Copy link
Owner

ok folks i got my 8 hours sleep in..

feeling better.

@Murph24
Copy link

Murph24 commented Dec 23, 2018

I did want to let you know that if you launch samsungctl from a script and not the command line you can keep the socket connection open to see if there is anything that is sent out the websocket when you do various things on the TV,

if you use this script it will print out debugging message if any messages come in the websocket

import samsungctl
import logging
import threading


logger = logging.getLogger('samsungctl')

logger.setLevel(logging.DEBUG)

config = {
    "name": "samsungctl",
    "description": "PC",
    "id": "",
    "host": "192.168.0.10",
    "port": 8002,
    "method": "websocket",
    "timeout": 0,
}

event = threading.Event()

with samsungctl.Remote(config) as remote:
    try:
        event.wait()
    except KeyboardInterrupt:
        pass

@kdschlosser Yes I've been wondering if any other events get fired on the socket. If I get some time later I'll run this and see. I don't think we'll see much given I don't see much in the log, but its worth a try.

@kdschlosser
Copy link
Owner

ok. so far we now have the voice control buttons.. YAY!!!!

and we now have a mechanism to lst off some of the content available from the eden applications.
we also have the way to get the application icons and also content images
and now we have the mechanism to start content on the TV.

we still do not know if the TV only responds to commends from the websocket or if it ever does any broadcasts to the websocket at all. we do know that the broadcast does exist and that it will send out through all connections we just do not know if the TV actually uses this at all.

@kdschlosser
Copy link
Owner

i have my work cut out for me. I need to create a wrapper class for the applications. and also another for the content. with properties and methods for starting the content/application . checking if it is running or not, getting the icons. I need to add methods for starting and stopping the voice recognition. turning on the mouse pointer and moving it as well as clicking the buttons.

@kdschlosser
Copy link
Owner

kdschlosser commented Dec 23, 2018

ok i added the voice recognition controls and the mouse controls there are separate branches for each. I still have to update the docs for the mouse. I have some errands I have to run today. I will be back in a few hours and I will work on this some more. The applications and content are going to take a few days to add. these are going to be pretty sizeable code additions.

@Murph24
Copy link

Murph24 commented Dec 23, 2018

Edit: Nevermind...downgrading websocket-client to 0.48.0 worked. (See other thread #5)

@kdschlosser I ran your script. Looks like it connects and then the websocket closes right away (or at least the message alludes to that). The program is still running although. Is this the expected behavior?

using saved token: 15673457
Websocket Connection Opened
incoming message: {"data":{"clients":[{"attributes":{"name":"c2Ftc3VuZ2N0bA==","token":"15673457"},"connectTime":1545602664396,"deviceName":"c2Ftc3VuZ2N0bA==","id":"e486b9f4-f942-4e3c-aa83-3057cbd72d8","isHost":false}],"id":"e486b9f4-f942-4e3c-aa83-3057cbd72d8"},"event":"ms.channel.connect"}

Access granted.
unorderable types: float() > NoneType()
Websocket Connection Closed

@Murph24
Copy link

Murph24 commented Dec 23, 2018

Ok so the websocket does get some events periodically, but not much. The only events I get from using the standard remote is from the voice control button. Nothing else (channel, volume, power off, etc.) seems to fire an event. Which brings up another potential issue...how does this library handle the tv being powered off by standard remote input? Right now the library thinks it has a connection after the tv is off. Maybe I'm missing something?

The other is a periodic Eden app update, which I guess is just publishing that an updated apps\programming list is available. Some of these Eden events below may have been triggered when I started the netflix app, but I'm not sure. I'll leave the websocket open this afternoon and see if anything good comes through.

using saved token: 15673457
Websocket Connection Opened
incoming message: {"data":{"clients":[{"attributes":{"name":"c2Ftc3VuZ2N0bA==","token":"15673457"},"connectTime":1545604590839,"deviceName":"c2Ftc3VuZ2N0bA==","id":"c4ab389-cf7c-4cce-a597-70eae7b1ada","isHost":false}],"id":"c4ab389-cf7c-4cce-a597-70eae7b1ada"},"event":"ms.channel.connect"}

Access granted.
incoming message: {"data":{"update_type":"ed.edenApp.update"},"event":"ed.edenTV.update"}

incoming message: {"data":{"update_type":"ed.edenApp.update"},"event":"ed.edenTV.update"}

incoming message: {"event":"ms.voiceApp.standby"}

incoming message: {"event":"ms.voiceApp.hide"}

incoming message: {"event":"ms.voiceApp.hide"}

incoming message: {"data":{"update_type":"ed.edenApp.update"},"event":"ed.edenTV.update"}

incoming message: {"data":{"update_type":"ed.edenApp.update"},"event":"ed.edenTV.update"}

incoming message: {"data":{"update_type":"ed.edenApp.update"},"event":"ed.edenTV.update"}

incoming message: {"data":{"update_type":"ed.edenApp.update"},"event":"ed.edenTV.update"}

@kdschlosser
Copy link
Owner

The problem with the websocket client should now be fixed. you will need to rerun setup.py this is force the installation of the latest version of the websocket-client.

@kdschlosser
Copy link
Owner

OK I have created 3 new branches. I am moving conversation for these branches to #9 so check there

@chrishawnm
Copy link

{"device":{"FrameTVSupport":"false","GamePadSupport":"true","ImeSyncedSupport":"true","OS":"Tizen","TokenAuthSupport":"true","VoiceSupport":"true","countryCode":"US","description":"Samsung DTV RCR","developerIP":"0.0.0.0","developerMode":"0","duid":"uuid:935b5c12-2769-4e4f-b75c-04035523e7a2","firmwareVersion":"Unknown","id":"uuid:935b5c12-2769-4e4f-b75c-04035523e7a2","ip":"192.168.0.2","model":"17_KANTM_UHD_BASIC","modelName":"UN55MU6300","name":"[TV] CMMU6300","networkType":"wireless","resolution":"3840x2160","smartHubAgreement":"true","ssid":"1c:49:7b:f6:3d:89","type":"Samsung SmartTV","udn":"uuid:935b5c12-2769-4e4f-b75c-04035523e7a2","wifiMac":"68:27:37:4D:4F:B4"},"id":"uuid:935b5c12-2769-4e4f-b75c-04035523e7a2","isSupport":"{"DMP_DRM_PLAYREADY":"false","DMP_DRM_WIDEVINE":"false","DMP_available":"true","EDEN_available":"true","FrameTVSupport":"false","ImeSyncedSupport":"true","TokenAuthSupport":"true","remote_available":"true","remote_fourDirections":"true","remote_touchPad":"true","remote_voiceControl":"true"}\n","name":"[TV] CMMU6300","remote":"1.0","type":"Samsung SmartTV","uri":"http://192.168.0.2:8001/api/v2/","version":"2.0.25"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests