sermayoral / ha-samsungtv-encrypted

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

Not control Samsung J6530 #16

Closed sacredx72 closed 4 years ago

sacredx72 commented 4 years ago

@sermayoral , Installed the component version master and 2.2, but both versions in the error log: When you try to form a team entity_id: media_player.samsung_room media_content_type: send_key media_content_id: KEY_CHDOWN

2020-04-02 21:52:03 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1770011216] extra keys not allowed @ data['media_content_type']
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1210, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 208, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 287, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 283, in _exec
    v = func(v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['media_content_type']

When you try to change the sound with the slider in the widget:

2020-04-02 21:44:27 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1770011216] 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1232, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1255, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 412, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 600, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 443, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 542, in async_set_volume_level
    await self.hass.async_add_job(self.set_volume_level, volume)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/samsungtv_encrypted/media_player.py", line 359, in set_volume_level
    self.SendSOAP(self._smp[0], self._urns[0], 'SetVolume',

The token and session number were received without problems through the execution request get_token.py

bash-5.0# python3 get_token.py --ip 192.168.169.9 --port 8080
ws://192.168.169.9:8000/socket.io/1/websocket/7hwVABdjBnbxQhAWRtVH
Current state: stopped
Pin NOT on TV
Please enter pin from tv: 2646
Got pin: '2646'

AES key: a133e693a5e73c64a5c82f9a26f03d2d
AES encrypted: 16*******6b7611ef4cdedd6645534ced4803208cc66ea
AES swapped: 79d90******422656f45f889478ccb3e53d1e49614357972a30d60dbc292
data buffer: 000000063*********C292
hash: feca1daaf7fdafe1b814fc2bd497096e27fd8eee
secondStepResponse: {"auth_data":"{\"auth_type\":\"SPC\",\"request_id\":\"0\",\"GeneratorClientHello\":\"01010**********2D1B58A2BDF800000000000\"}"}

thirdLen: 138
hello: 01010********d308230e721542d1b58a2bdf800000000000
dest: 0000000636**********27fd8eee
userId: 654321
pEncWBGx: b25809d*********40add528822f828f1c170ba72
pEncGx: 1fff9bc859********a920a982b4c0d9262437ef
pGx: 1b9d430*********38b375f83647a65a0fe59381aa4e6e04b5a38074a0d26c
secret: 9be7***********17cda8492bfcee5acd38e92c39
hash2: 0461e27**********8a2bdf80
secret2: 363534*********5acd38e92c39
hash3: 0461e277169*******21542d1b58a2bdf80
Pin OK :)

dest_hash: c6098041ec*******07b2a6ec187f8cbf5
SKPrime: df142da193b********9046f652a21ff98d
SKPrimeHash: abdac4dd21********4c70c48d476ca149
ctx: 1e66f533***cf950286123
Pin accepted :)

sessionId: 3
SessionID: 3
Authorization successfull :)

Config Home Assistant 0.108.0b0

  - platform: samsungtv_encrypted
    name: samsung_room
    host: 192.168.169.9
    token: 2646
    sessionid: 3
    port: 8080

Can someone tell me what the problem is, in HA only the On / Off status is displayed. The sound level is not displayed, the command does not accept P.s TV response at http://192.168.169.9:8001/api/v2/

{
  "id": "uuid:409*******************b803",
  "name": "[TV] UE48J6530",
  "version": "2.0.25",
  "device": {
    "type": "Samsung SmartTV",
    "duid": "uuid:40951******************b803",
    "model": "15_HAWKM_2D",
    "modelName": "UE48J6300",
    "description": "Samsung DTV RCR",
    "networkType": "wired",
    "ssid": "",
    "ip": "192.168.169.9",
    "firmwareVersion": "Unknown",
    "name": "[TV] UE48J6530",
    "id": "uuid:40951**********1b803",
    "udn": "uuid:409518***********31b803",
    "resolution": "1920x1080",
    "countryCode": "RU",
    "msfVersion": "2.0.25",
    "smartHubAgreement": "true",
    "wifiMac": "f8:********:e1",
    "developerMode": "0",
    "developerIP": ""
  },
  "type": "Samsung SmartTV",
  "uri": "http://192.168.169.9:8001/api/v2/"
sacredx72 commented 4 years ago

If you need to conduct any tests, then I will perform any action. Your custom component is the only one that was able to request an authorization PIN from the TV =)

pablolassalle commented 4 years ago

The token and session number were received without problems through the execution request get_token.py

bash-5.0# python3 get_token.py --ip 192.168.169.9 --port 8080
ws://192.168.169.9:8000/socket.io/1/websocket/7hwVABdjBnbxQhAWRtVH
Current state: stopped
Pin NOT on TV
Please enter pin from tv: 2646
Got pin: '2646'

AES key: a133e693a5e73c64a5c82f9a26f03d2d
AES encrypted: 16*******6b7611ef4cdedd6645534ced4803208cc66ea
AES swapped: 79d90******422656f45f889478ccb3e53d1e49614357972a30d60dbc292
data buffer: 000000063*********C292
hash: feca1daaf7fdafe1b814fc2bd497096e27fd8eee
secondStepResponse: {"auth_data":"{\"auth_type\":\"SPC\",\"request_id\":\"0\",\"GeneratorClientHello\":\"01010**********2D1B58A2BDF800000000000\"}"}

thirdLen: 138
hello: 01010********d308230e721542d1b58a2bdf800000000000
dest: 0000000636**********27fd8eee
userId: 654321
pEncWBGx: b25809d*********40add528822f828f1c170ba72
pEncGx: 1fff9bc859********a920a982b4c0d9262437ef
pGx: 1b9d430*********38b375f83647a65a0fe59381aa4e6e04b5a38074a0d26c
secret: 9be7***********17cda8492bfcee5acd38e92c39
hash2: 0461e27**********8a2bdf80
secret2: 363534*********5acd38e92c39
hash3: 0461e277169*******21542d1b58a2bdf80
Pin OK :)

dest_hash: c6098041ec*******07b2a6ec187f8cbf5
SKPrime: df142da193b********9046f652a21ff98d
SKPrimeHash: abdac4dd21********4c70c48d476ca149
ctx: 1e66f533***cf950286123
Pin accepted :)

sessionId: 3
SessionID: 3
Authorization successfull :)

Config Home Assistant 0.108.0b0

  - platform: samsungtv_encrypted
    name: samsung_room
    host: 192.168.169.9
    token: 2646
    sessionid: 3
    port: 8080

Hi @sacredx72, I can see you used your pin as a token, which is wrong, as the README explain, your token should be the "ctx" value you get from the get_token.py. so, your token in the case showed above is: 1e66f533cf950286123

dest_hash: c6098041ec07b2a6ec187f8cbf5 SKPrime: df142da193b9046f652a21ff98d SKPrimeHash: abdac4dd214c70c48d476ca149 ctx: 1e66f533cf950286123 Pin accepted :)

sessionId: 3 SessionID: 3 Authorization successfull :)

So, your config file in homeassistant should look like this:

sacredx72 commented 4 years ago

Thank you so much ! It all worked! I've tried so many different custom components and only yours changes the sound!