sermayoral / ha-samsungtv-encrypted

Samsung TV Encrypted Models (H & J Series) custom component for Home Assistant
Apache License 2.0
39 stars 24 forks source link

Get_token.py errors #5

Closed KixMan28 closed 4 years ago

KixMan28 commented 4 years ago

Hi! I try to use your integration, but when I run the get_token.py I get the following error:

Traceback (most recent call last): File "get_token.py", line 3, in <module> from PySmartCrypto.pysmartcrypto import PySmartCrypto File "C:\samsungtv_encrypted\PySmartCrypto\pysmartcrypto.py", line 2, in <module> from . import crypto File "C:\samsungtv_encrypted\PySmartCrypto\crypto.py", line 2, in <module> from Crypto.Cipher import AES ImportError: No module named Crypto.Cipher What I am doing wrong?

jfg31113 commented 4 years ago

I have the same problem:

C:\b\sam>python get_token.py --ip 192.168.0.14 --port 8080
Traceback (most recent call last):
  File "get_token.py", line 3, in <module>
    from PySmartCrypto.pysmartcrypto import PySmartCrypto
  File "C:\b\sam\PySmartCrypto\pysmartcrypto.py", line 2, in <module>
    from . import crypto
  File "C:\b\sam\PySmartCrypto\crypto.py", line 2, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'

I have tried on my raspberry pi and on my Pc (windows10), get the same error.

rpcaeiro commented 4 years ago

Hi, I'm facing the same problem as jfg31113 python3 get_token.py --ip 192.168.10.90 --port 8080

I'm running the command from the HA shell. Thanks

KixMan28 commented 4 years ago

I have solved my problem. I did this on my Windows 10, with Python 3.8.2. I downloaded the integration ZIP file from here and I unzipped it In Windows command line (Run - cmd) I changed directory to samsungtv-encrypted and I ran the following commands: pip install pycryptodome

To test if everything went OK (you need to wait couple of minutes before it completes): python -m Crypto.SelfTest pip install requests pip install websocket_client get_token.py --ip XXX.XXX.XXX.XXX --port 8080 ` where I replaced XXX.XXX.XXX.XXX with my TV's IP address.

I hope I could help others.

sermayoral commented 4 years ago

You have to install the pycrypto module.

I have in mind executing the get_token.py in Home Assistant first time you use the custom, but I must think the best way to do it :-)

rpcaeiro commented 4 years ago

Thank you KixMan28. Get_token works with your steps.

rpcaeiro commented 4 years ago

You have to install the pycrypto module.

I have in mind executing the get_token.py in Home Assistant first time you use the custom, but I must think the best way to do it :-)

That will be great, thanks Until then I think you should update your instructions to add how to use the get_token with python for windows. For me worked fine with HU8500. It seems I only can change source, control volume and turn it off. How can I send channel up or down?

rpcaeiro commented 4 years ago

Upsss of course, now I can send any key like “KEY_CHUP”. Nice. I waited long time for this. Thank you so much sermayoral.

KixMan28 commented 4 years ago

Upsss of course, now I can send any key like “KEY_CHUP”. Nice. I waited long time for this. Thank you so much sermayoral.

How you do that? I was looking for the same thing, but I could not find a solution. Also How can I switch on the TV?

rpcaeiro commented 4 years ago

Hi KixMan28, Just follow the instructions of the SamsungTV Custom integration. :)

KixMan28 commented 4 years ago

OK, I will try that.

Another question: my media_player.samsung_tv_remote entity has the following attributes:

source_list:

What does this mean: "supported_features: 20285"?

sermayoral commented 4 years ago

OK, I will try that.

Another question: my media_player.samsung_tv_remote entity has the following attributes:

source_list:

  • TV
  • HDMI1
  • HDMI2
  • HDMI3
  • SCART
  • AV volume_level: 0.15 is_volume_muted: false source: HDMI1 friendly_name: Samsung TV Remote supported_features: 20285 device_class: tv

What does this mean: "supported_features: 20285"?

https://community.home-assistant.io/t/how-to-read-interpret-supported-features/114152

rpcaeiro commented 4 years ago

Hi KixMan28, Today I will explore more keys calling this Media player service. { "entity_id": "media_player.samsungtv", "media_content_type": "send_key", "media_content_id": "KEY_CODE", } But I’m particularly interested in calling the Netflix app. I think my tv don’t support calling it remotely. Anyway, I will try. All the keys are here: https://github.com/roberodin/ha-samsungtv-custom/blob/master/README.md

KixMan28 commented 4 years ago

Hi @rpcaeiro ! Thank you for the link. I succeeded to filter out the features which are supported by my Samsung TV, which is by the way an UE40H6400AK.

I still don't get the part with the key calling. Maybe you can share with me another link where I can read more about it.

sermayoral commented 4 years ago

@rpcaeiro you are right, I should add the send_key functionality in the documentation. I will do it as soon as possible.

I think there is not a media_player.channel_up/down service available, Isn't it? So, the only way to change channels is invoking this service.

@KixMan28 you have to invoke the media_player.play_media with this parameters:

Screenshot_20200321-170149

rpcaeiro commented 4 years ago

Hi Sergio, thank you Hi Kixman28, what Sergio posted is exactly what I’m doing to change channel or to send any remote key command supported by my TV. Should work.

sermayoral commented 4 years ago

@rpcaeiro please share your tests sending commands 😊. It would be very nice open Netflix or Youtube with a command, but I think its not possible... Or maybe yes...

sermayoral commented 4 years ago

By the way, If the custom work for you, stars in the repo are welcome... 😊

KixMan28 commented 4 years ago

Hi Sergio, thank you Hi Kixman28, what Sergio posted is exactly what I’m doing to change channel or to send any remote key command supported by my TV. Should work.

OK, it is clear now. I will start testing my TV with these key codes. I will let you know the result.

sermayoral commented 4 years ago

@rpcaeiro @KixMan28 great :-)

Please guys, can you share your conclusions in https://github.com/sermayoral/ha-samsungtv-encrypted/issues/9? To let this issue for get_token.py problems...

Thanks!!

jfg31113 commented 4 years ago

Finally got it working, but it says samsung_tv_remote CapturaZZZ

rpcaeiro commented 4 years ago

Hi jfg, Yes, that’s the default, but you can change it to whatever you want in HA.

tubes41 commented 4 years ago

@sermayoral, this error is still an issue https://github.com/sermayoral/ha-samsungtv-encrypted/issues/5#issuecomment-601482275 Comment #5 does not fix it for HASS OS users on Raspberry Pi. We have no way to run pip. The manifest needs to include all requirements.

JuhaHi commented 4 years ago

You have to install the pycrypto module.

I have in mind executing the get_token.py in Home Assistant first time you use the custom, but I must think the best way to do it :-)

Hi, Please do that. I'm so noob that I cannot understand anything about Python or anything else.

matteos1 commented 3 years ago

I have solved my problem. I did this on my Windows 10, with Python 3.8.2. I downloaded the integration ZIP file from here and I unzipped it In Windows command line (Run - cmd) I changed directory to samsungtv-encrypted and I ran the following commands: pip install pycryptodome

To test if everything went OK (you need to wait couple of minutes before it completes): python -m Crypto.SelfTest pip install requests pip install websocket_client get_token.py --ip XXX.XXX.XXX.XXX --port 8080 ` where I replaced XXX.XXX.XXX.XXX with my TV's IP address.

I hope I could help others.

python get_token.py --ip XXX.XXX.XXX.XXX --port 8080

jeanbart82 commented 3 years ago

I have solved my problem. I did this on my Windows 10, with Python 3.8.2. I downloaded the integration ZIP file from here and I unzipped it In Windows command line (Run - cmd) I changed directory to samsungtv-encrypted and I ran the following commands: pip install pycryptodome To test if everything went OK (you need to wait couple of minutes before it completes): python -m Crypto.SelfTest pip install requests pip install websocket_client get_token.py --ip XXX.XXX.XXX.XXX --port 8080 ` where I replaced XXX.XXX.XXX.XXX with my TV's IP address. I hope I could help others.

python get_token.py --ip XXX.XXX.XXX.XXX --port 8080

Thanks this exactly what i needed for my UE55HU7500LXXN

steeegraham commented 3 years ago

someone please help me! I'm going round in circles.. I have python 2.7 in C:\Python27 I've also installed the latest version 3.9 which seems to have installed in an appdata folder called C:\Users\\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0 I've extracted the Github package from https://github.com/sermayoral/ha-samsungtv-encrypted to C:\Users\\Documents\samsungtv_encrypted I ran 'pip install crypto' successfully I ran 'pip install pycryptodome' successfully I'm unable to run 'pip3 install pycrypto' successfully running 'python get_token.py --ip 192.168.1.xxx --port 8080' ends in error "ImportError: No module named Crypto.Cipher" running 'python3 get_token.py --ip 192.168.1.xxx --port 8080' ends in error "ImportError: bad magic number in 'PySmartCrypto.crypto': b'\x03\xf3\r\n' " I've tried uninstalling all the modules and reinstalling them trying one by one, always reaching the same errors. I've had to rename crypto.py to Crypto.py but can't find a folder called \crypto\ anywhere on my Windows 10 system. I feel like I'm so close to getting this working but missing something simple. The config of my Python setup, I suspect is the cause but python is used for other bits and bobs like flashing chips so don't really want to completely uninstall 2.7 for fear of losing the modules for flashing esp's etc etc. Please help!