Samsung TV 2014 H Series not working

I need have a look of this.

Please, could you open a ticket with this information in https://github.com/sermayoral/ha-samsungtv-encrypted/issues?

I cant get the get_token.py to work…
I’v installed successfully websocket and websocket-client in a Raspbian Environment.
But when i execute

python3 get_token.py --ip 192.168.178.24 --port 8080

ill get the following error:

Traceback (most recent call last):
  File "get_token.py", line 3, in <module>
    from PySmartCrypto.pysmartcrypto import PySmartCrypto
  File "/home/pi/Downloads/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 8, in <module>
    import websocket
ImportError: No module named 'websocket'

Do you know any further troubleshooting?

1 Like

I’v tried to reinstall the websocket module. Now i’ll get different error:


ws://192.168.178.24:8000/socket.io/1/websocket/vr1LvV1xjmMmtiOcAOkn
Traceback (most recent call last):
  File "get_token.py", line 27, in <module>
    main(sys.argv[1:])
  File "get_token.py", line 24, in main
    PySmartCrypto(ip, port)
  File "/home/pi/Downloads/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 123, in __init__
    self._connection = self.connect()
  File "/home/pi/Downloads/ha-samsungtv-encrypted/custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py", line 99, in connect
    connection = websocket.create_connection(websocket_url)
AttributeError: module 'websocket' has no attribute 'create_connection'

It’s work
pip3 install websocket
pip3 install websocket-client
python3 get_token.py -i 192.168.x.x -p 8080

2 Likes

Hi,

Never used Python before so apologies

I have installed Python 3.8 from https://www.python.org/ onto my Win10 PC

I then went to open get_token.py and get

I then run module and get
image

How do I install the module Cypto?

I have tried
pip3 install pycrypto

get
image

Regards,

Hi, you must run this outside of the Python shell. Like normal Windows Command Line or so.

Hi,
Yeah I figured that out myself, thanks, however…

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    building 'Crypto.Random.OSRNG.winrandom' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\mark\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Mark\\AppData\\Local\\Temp\\pip-install-kk7uu6hv\\pycrypto\\setup.py'"'"'; __file__='"'"'C:\\Users\\Mark\\AppData\\Local\\Temp\\pip-install-kk7uu6hv\\pycrypto\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Mark\AppData\Local\Temp\pip-record-zoj54f0c\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\mark\appdata\local\programs\python\python38-32\Include\pycrypto' Check the logs for full command output.

C:\Users\Mark>

Had a look at https://visualstudio.microsoft.com/visual-cpp-build-tools/ but do not know what packages I need?

Now I have got this far…

C:\Users\Mark>pip install crypto.py
Collecting crypto.py
  Downloading Crypto-Py-0.0.4.tar.gz (4.3 kB)
Requirement already satisfied: pycryptodome in c:\users\mark\appdata\local\programs\python\python38-32\lib\site-packages (from crypto.py) (3.9.7)
Installing collected packages: crypto.py
    Running setup.py install for crypto.py ... done
Successfully installed crypto.py

C:\Users\Mark>python get_token.py
Traceback (most recent call last):
  File "get_token.py", line 3, in <module>
    from PySmartCrypto.pysmartcrypto import PySmartCrypto
ModuleNotFoundError: No module named 'PySmartCrypto'

Okay,
Some success after a lot of Googling.
I am Running Win 10 and Python 3.8.2
From the command line

pip install crypto

Renamed folder crypto to Crypto


from cmd prompt typed python

help (“modules”)

C:\Users\Mark>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help ("modules")

Please wait a moment while I gather a list of all available modules...

Crypto              _tracemalloc        gevent              sched
Crypto_Py           _warnings           glob                secrets
Naked               _weakref            greenlet            select
__future__          _weakrefset         gzip                selectors
_abc                _winapi             hashlib             setuptools
_ast                _xxsubinterpreters  heapq               shellescape
_asyncio            _yaml               hmac                shelve
_bisect             abc                 html                shlex
_blake2             aifc                http                shutil
_bootlocale         antigravity         idlelib             signal
_bz2                argparse            idna                site
_cffi_backend       array               imaplib             six
_codecs             ast                 imghdr              smtpd
_codecs_cn          asynchat            imp                 smtplib
_codecs_hk          asyncio             importlib           sndhdr
_codecs_iso2022     asyncore            inspect             socket
_codecs_jp          atexit              io                  socketserver
_codecs_kr          audioop             ipaddress           sqlite3
_codecs_tw          base64              itertools           sre_compile
_collections        bdb                 json                sre_constants
_collections_abc    binascii            keyword             sre_parse
_compat_pickle      binhex              lib2to3             ssl
_compression        bisect              linecache           stat
_contextvars        builtins            locale              statistics
_csv                bz2                 logging             string
_ctypes             cProfile            lzma                stringprep
_ctypes_test        calendar            mailbox             struct
_datetime           certifi             mailcap             subprocess
_decimal            cffi                marshal             sunau
_dummy_thread       cgi                 math                symbol
_elementtree        cgitb               mimetypes           symtable
_functools          chardet             mmap                sys
_hashlib            chunk               modulefinder        sysconfig
_heapq              cmath               msilib              tabnanny
_imp                cmd                 msvcrt              tarfile
_io                 code                multiprocessing     telnetlib
_json               codecs              netrc               tempfile
_locale             codeop              nntplib             test
_lsprof             collections         nt                  textwrap
_lzma               colorsys            ntpath              this
_markupbase         compileall          nturl2path          threading
_md5                concurrent          numbers             time
_msi                configparser        opcode              timeit
_multibytecodec     contextlib          operator            tkinter
_multiprocessing    contextvars         optparse            token
_opcode             copy                os                  tokenize
_operator           copyreg             parser              trace
_osx_support        crypt               pathlib             traceback
_overlapped         csv                 pdb                 tracemalloc
_pickle             ctypes              pickle              tty
_py_abc             curses              pickletools         turtle
_pydecimal          dataclasses         pip                 turtledemo
_pyio               datetime            pipes               types
_queue              dbm                 pkg_resources       typing
_random             decimal             pkgutil             unicodedata
_sha1               difflib             platform            unittest
_sha256             dis                 plistlib            urllib
_sha3               distutils           poplib              urllib3
_sha512             doctest             posixpath           uu
_signal             dummy_threading     pprint              uuid
_sitebuiltins       easy_install        profile             venv
_socket             email               pstats              warnings
_sqlite3            encodings           pty                 wave
_sre                ensurepip           py_compile          weakref
_ssl                enum                pyclbr              webbrowser
_stat               errno               pycparser           websocket
_statistics         faulthandler        pydoc               winreg
_string             filecmp             pydoc_data          winsound
_strptime           fileinput           pyexpat             wsgiref
_struct             fnmatch             queue               xdrlib
_symtable           formatter           quopri              xml
_testbuffer         fractions           random              xmlrpc
_testcapi           ftplib              re                  xxsubtype
_testconsole        functools           reprlib             yaml
_testimportmultiple gc                  requests            zipapp
_testmultiphase     genericpath         rlcompleter         zipfile
_thread             getopt              runpy               zipimport
_threading_local    getpass             samsungtv           zlib
_tkinter            gettext             samsungtv_encrypted

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".

Thanks spectreman.
In my instance python get_token.py -i 192.168.0.220 -p 8080

C:\Users\Mark\samsungtv_encrypted>python get_token.py -i 192.168.0.220 -p 8080
ws://192.168.0.220:8000/socket.io/1/websocket/6gpWDaiHEcrt8Mz1AT2m
Current state: stopped
Pin NOT on TV
Please enter pin from tv: 3429
Got pin: '3429'

AES key: 8989b4ab2b11de2490047c598e9cdef0
AES encrypted: 783434f279c10da6ff7d03ed79a89a037974baf448a02e6914997da0d2347b64d6fecc3f2212f9f860c4cd2208458b1016524c1c0db922851cdeaa3014449f7ea702200fa7fba43b63834c798b5af313b6a0d741f89c5d4e08dad1965317b63ab69139fdc10a1859de7d1c9004f8d3cdf845fa4debba94a7904b748bad4034bb
AES swapped: ad9110eaef370f4cb8112a51400d632a6e93aa64286dcf1a0ffa23b72b7f023532e00861597812f22d0d7bb68eac7507706ee8f43d866cfda0cb522a44124941d74f2f94de142ef6575ccb8af846a4ad23ce78a3b041080231f4648f9f40232c365691c846c7adc53c602836582f95255b45f1fd782911345b0385087e4a2035
data buffer: 00000006363534333231AD9110EAEF370F4CB8112A51400D632A6E93AA64286DCF1A0FFA23B72B7F023532E00861597812F22D0D7BB68EAC7507706EE8F43D866CFDA0CB522A44124941D74F2F94DE142EF6575CCB8AF846A4AD23CE78A3B041080231F4648F9F40232C365691C846C7ADC53C602836582F95255B45F1FD782911345B0385087E4A2035
hash: 4ccc3fca9f35151d377c636da7b0f8f8d7fe68be
secondStepResponse: {"auth_data":"{\"auth_type\":\"SPC\",\"request_id\":\"0\",\"GeneratorClientHello\":\"010100000000000000009E0000000636353433323169A8EBD90978638E213D716ADC94C47AF6203514584D730C035EE57DA27CA8AAC3A0E40C6AF2E2536647919F543991A941C714FAA371FBA6407B3A2941B48AA72F7A029DDB202FBC2739191258A9ECDBE42363B74AFE52D3DDA290C9417B285E9063366FA2A6776152C5B024FBFAE8252FE76A5FF7A319C6AB71A08C450AF08424577B7138886B507E574650E1B59DD56CB356DE0000000000\"}"}


thirdLen: 138
hello: 010100000000000000009e0000000636353433323169a8ebd90978638e213d716adc94c47af6203514584d730c035ee57da27ca8aac3a0e40c6af2e2536647919f543991a941c714faa371fba6407b3a2941b48aa72f7a029ddb202fbc2739191258a9ecdbe42363b74afe52d3dda290c9417b285e9063366fa2a6776152c5b024fbfae8252fe76a5ff7a319c6ab71a08c450af08424577b7138886b507e574650e1b59dd56cb356de0000000000
dest: 0000000636353433323169a8ebd90978638e213d716adc94c47af6203514584d730c035ee57da27ca8aac3a0e40c6af2e2536647919f543991a941c714faa371fba6407b3a2941b48aa72f7a029ddb202fbc2739191258a9ecdbe42363b74afe52d3dda290c9417b285e9063366fa2a6776152c5b024fbfae8252fe76a5ff7a319c6ab71a08c450af0844ccc3fca9f35151d377c636da7b0f8f8d7fe68be
userId: 654321
pEncWBGx: 69a8ebd90978638e213d716adc94c47af6203514584d730c035ee57da27ca8aac3a0e40c6af2e2536647919f543991a941c714faa371fba6407b3a2941b48aa72f7a029ddb202fbc2739191258a9ecdbe42363b74afe52d3dda290c9417b285e9063366fa2a6776152c5b024fbfae8252fe76a5ff7a319c6ab71a08c450af084
pEncGx: 1a3a68b685d34a85cd150e73332e9061e0960640103c2d3f79205f0f6ae011e8714b3390bca129015cd8be207d59243458ae9b19f7caa16b1050e037fa3f5c8339cd7309b86b78147f29a706680a4e3cfb135ec52474d97923764344dc39a50bb76a9cc9ab23186d0f794165c9eda3b256c186845e2e74b46d5f9fdd8a1e3150
pGx: 3c22063ce58b5b80cd75cd815e8ed4a33a09832d7cc458e56643de16cd261fdb70bc051a45afceef4740167fd19dc19adff491e536e8f84f2ca762f5379368a15a5f67ee2a02f8797933cd775e2fcdc902e327d37ecea81b1968f35885212412bff8ddb583c266e9b204d260dd95e7fa709352638a3f78cd4905a48b7e7639fa
secret: 3c3d855035feda1654dc344fbc260bd9f1ce369b2bd8f4c04658b6fb9ca4210c49a9b10af7dc2592b1960d17bc09e15ee13db639baf64c6548fd65d24f151c9d26c773a25fa8cba840410568a374a3662be3e9969c12a893438582a50afc3f7dd006bcbe890fca39646014f1faa086da3d15d214dc37c3e75d13f11005bbd440
hash2: 24577b7138886b507e574650e1b59dd56cb356de
secret2: 3635343332313c3d855035feda1654dc344fbc260bd9f1ce369b2bd8f4c04658b6fb9ca4210c49a9b10af7dc2592b1960d17bc09e15ee13db639baf64c6548fd65d24f151c9d26c773a25fa8cba840410568a374a3662be3e9969c12a893438582a50afc3f7dd006bcbe890fca39646014f1faa086da3d15d214dc37c3e75d13f11005bbd440
hash3: 24577b7138886b507e574650e1b59dd56cb356de
Pin OK :)

dest_hash: 767c3ddedd58078e2e77a6e4add8e4f5e2256cec
SKPrime: 71d7d03ca00735caf80cd5232f49c36245d6ce0f
SKPrimeHash: 1dfcae0b1774a1fb38789d6b9306a76365eaee4f
ctx: a8dcf55ae255075c660243d53ea05093
Pin accepted :)

sessionId: 2
SessionID: 2
Authorization successfull :)

so my configuration.yaml

media_player:
  - platform: samsungtv_encrypted
    host: 192.168.0.220
    token: a8dcf55ae255075c660243d53ea05093
    sessionid: 2
    port: 8080

Hope this helps others.

I can control the Source, Volume and Switch Off functions, is there a way to switch on?

Regards,

2 Likes

The only way you can turn on your TV is connecting your Home Assistant Device to your TV using a HDMI cable, and using the hdmi version of the component: https://github.com/sermayoral/ha-samsungtv-encrypted/releases/tag/v2.3-hdmi

These encrypted models don’t support turning on using LAN :frowning:

Official samsungtv integration supports turn_on_action option, which can be set to any action. Is that possible to add the same here? I have IR remote and easily can turn tv on using it.

Hi Mark, I’m unable to do as you…
I installed Python 3.8.3 for Python.org, I can open the shell and everything seem good.
But from my command line when I enter pip install crypto I had the error that “pip” is not recognized as command or program…

Can you help?

type python at command prompt.

Regards,

Hi, im nubby of python…
I’m trying to install the tv on hassio, I installed python on the windows’s laptop I followed the whole conversation and when I try to give the following commands I get this error … what can I try?

Did you do the following?

Regards,

Yes many time …

well i tryed many road, at the end
the script say me:
current state stoped
pin NOT on tv…
i run on samsung tv h6203
what can i also try?
thank you so much

Hey! Have you seen my message about adding turn_on_action option? Is that possible that you’ll work on that?