Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Some TV models request authorization again after every reboot #16

Open
thefrenchmatt opened this issue Apr 17, 2016 · 12 comments
Open

Some TV models request authorization again after every reboot #16

thefrenchmatt opened this issue Apr 17, 2016 · 12 comments
Labels

Comments

@thefrenchmatt
Copy link

thefrenchmatt commented Apr 17, 2016

Dear @Ape ,

based on this library, home-assistant.io requests a new connection each time but it seems some models should be able to remember the host based on MAC address.

Could you be so kind as to add an optional conf variable for it?

I found a practical example that may help here : http://deneb.homedns.org/things/?p=232

@Ape
Copy link
Owner

Ape commented Apr 17, 2016

It's currently possible to keep the connection open and send multiple control messages. I don't see how the MAC address helps here. What is your use case here?

@thefrenchmatt
Copy link
Author

Yes but as soon as the tv or server is turned off, access is requested again. This does not happen for DNLA servers or a mobile devices (incl. Apps started from those). So I'm looking for a way to pass the MAC Adress and home-automation.io uses your work, so I guessed best to ask you (:

@Ape
Copy link
Owner

Ape commented Apr 20, 2016

Hmm. It doesn't request for the access again after rebooting on the models I have tested. But different models may behave differently.

Should sending the MAC address fix this? I would be happy to fix the behavior, but I cannot test it myself. Feel free to play with the source code and please send me a pull request if you get it working better.

@Ape Ape changed the title host MAC address? Some TV models request authorization again after every reboot Apr 20, 2016
@thefrenchmatt
Copy link
Author

My skills are not that advanced but I will surely try comparing your code with the link I initially attached.

@jviyer
Copy link

jviyer commented Aug 8, 2016

I get this error: when I run the program.
I called samsungct as follows:

samsungctl --host 192.168.1.6 --name samsungctl KEY_MUTE
Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 9, in <module> load_entry_point('samsungctl==0.5.1', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl/__main__.py", line 99, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl/remote.py", line 38, in __init__ self._read_response(True) File "/usr/local/lib/python2.7/dist-packages/samsungctl/remote.py", line 70, in _read_response tv_name_len = int.from_bytes(header[1:3],
My conf is as follows:
{
"name": "samsungctl",
"description": "PC",
"id": "",
"port": 55000,
"timeout": 0

}

@Ape
Copy link
Owner

Ape commented Aug 8, 2016

@jviyer You need to use Python 3. E.g. pip3 install samsungctl

@jviyer
Copy link

jviyer commented Aug 13, 2016

Thanks a lot ! That was the issue.

On Monday, August 8, 2016 2:11 AM, Lauri Niskanen <notifications@github.com> wrote:

@jviyer You need to use Python 3. E.g. pip3 install samsungctl—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@Upas
Copy link

Upas commented Jan 20, 2017

@Ape Thanks for an amazing lib.
I have faced the re-authorization issue as well. Having the MAC address in the request seems to solve the issue. I have modified the remote_legacy.py code to include mac address, like so

payload = b"\x64\x00" \ + self._serialize_string(config["description"]) \ + self._serialize_string(config["mac"]) \ + self._serialize_string(config["id"]) \ + self._serialize_string(config["name"])
One would also need to append the config to include "mac":
, "mac":"00-AB-11-11-11-11"

PS: very new to github. I tried a few times but wasn't sure how to use the pull request
i have created a pull request with the changes now
Cheers!

@Ape
Copy link
Owner

Ape commented Jan 20, 2017

@Upas Thanks for the pull request #24. Does it matter what is inserted as the MAC address? Should it be the PC or TV address?

@Upas
Copy link

Upas commented Jan 20, 2017

I apologize.
I might have gotten too excited to have found a fix. But in retrospect no additions are needed, the additional "mac" item can be left out. This can still be made to work with just the 3 parameters in the string serialize.

Some findings i have made from testing on my TV are listed below.
Based on your existing payload string:
payload = b"\x64\x00" \ + self._serialize_string(config["description"]) \ + self._serialize_string(config["id"]) \ + self._serialize_string(config["name"])

  1. "description" - should ideally be the IP address of the device (can be any thing, no enforcement here). This is not affected by change across sessions.
  2. "id" - should ideally be the MAC. Again no enforcement. This value can be anything, BUT should remain constant across sessions. If it is changed TV will ask for re-auth.
  3. "name" - Is the name of the remote. This remains as is and is also not affected by change across sessions.

So i guess the short is - a little clean up of naming of the payload components and the example should clear this up for all the folks having re-auth issues.

I have modified payload in remote_legacy.py as follows:
payload = b"\x64\x00" \ + self._serialize_string(config["ip"]) \ + self._serialize_string(config["mac"]) \ + self._serialize_string(config["name"])

and config like so:
{
"ip": "192.168.0.2013", # ideally should be the IP of the device, but you can use anything
"mac": "mac:address:1",
"name": "Python Remote1",

    "host": "192.168.0.101",
    "port": 55000,
    "method": "legacy",
    "timeout": 0

}

robertoostenveld added a commit to robertoostenveld/samsungctl that referenced this issue May 1, 2017
When id is empty, I explicitly have to authorise remote control on the TV on every start of samsungctl. When id is non-empty, it stores the authorization properly on the TV. Giving it a non-empty value in the example might save others the time it took me to figure out.

See also issue Ape#16, although that has to do with re-authorisation after a reboot (which I dit not observe).
@pedrinho
Copy link
Contributor

pedrinho commented Jul 2, 2017

Setting "mac" and "ip" solved my problem with re-authentication on every restart on my UN40F5500 TV.

BTW @Ape thanks so much on lib, I'm using it on https://github.com/pedrinho/samsung_remote

@adeeltahir98
Copy link

adeeltahir98 commented May 28, 2020

How to solve this re-authentication problem using websockets method instead of legacy ?

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

No branches or pull requests

6 participants