Samsung TV 2014 H Series not working

Are you the PR author?? @m0thman

Hi. No, unfortunately I’m not @sermayoral

Someone have implemented it, so it will be available very soon :blush:

Yay! Can not wait. Push it push it push it!

My 2 samsung TVs entities are simply gone after updated to Home Assistant 0.115.
Any suggestions? Thanks!!

Here’s the log:

Logger: homeassistant.components.media_player
Source: custom_components/samsungtv_encrypted/media_player.py:129 
Integration: Media player (documentation, issues) 
First occurred: 8:29:34 PM (2 occurrences) 
Last logged: 8:29:34 PM

Error while setting up samsungtv_encrypted platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/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 129, in setup_platform
    turn_on_action = Script(hass, turn_on_action)
TypeError: __init__() missing 2 required positional arguments: 'name' and 'domain'

Here’s the config:

media_player:
  - platform: samsungtv_encrypted
    host: !secret samsungtv_encrypted_sala_host
    token: !secret samsungtv_encrypted_sala_token
    sessionid: !secret samsungtv_encrypted_sala_sessionid
    port: !secret samsungtv_encrypted_sala_port
    name: sala_tv
    turn_on_action:
      - service: switch.turn_on
        data:
          entity_id: switch.samsung_tv_power

  - platform: samsungtv_encrypted
    host: !secret samsungtv_encrypted_suite_host
    token: !secret samsungtv_encrypted_suite_token
    sessionid: !secret samsungtv_encrypted_suite_sessionid
    port: !secret samsungtv_encrypted_suite_port
    name: suite_tv
    turn_on_action:
      - service: switch.turn_on
        data:
          entity_id: switch.samsung_tv_power

I encountered a similar error with a different custom component.

The Script() help class has been changed and now requires two extra parameters.

I had to edit the Python file for my one (timedcovers) and change:
self._open_script = Script(hass, open_action)
to:
self._open_script = Script(hass, open_action,friendly_name,domain)

The change that broke this is:

There is already a release that solves this issue :slight_smile:

I’m trying to get the token for my TV and got stuck in the PySmartCrypto error…
I have tried installing the pycrypto and the pycryptodome packages as below, but I’m still getting the same error…

pycrypto 2.6.1
pycryptodome 3.9.8

This is the command output:

root@ubuntu:/home/andre/Public# python3 get_token.py --ip 192.168.0.190 --port 8080
Traceback (most recent call last):
File “get_token.py”, line 3, in
from PySmartCrypto.pysmartcrypto import PySmartCrypto
ModuleNotFoundError: No module named ‘PySmartCrypto’

I’m getting this both on my Ubuntu and on my Mac laptop…
What can I do to make it work??

So, what is the solution to turn on this TV ?
Key_HDMIx doesnt work anymore.

I keep getting:

requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘p’, port=8000): Max retries exceeded with url: /socket.io/1/?t=1604279152209 (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0xb5dd8a30>: Failed to establish a new connection: [Errno -5] No address associated with hostname’))

at the end of a page of errors. Finally met the dependencies, but this is baffling me.

I inserted the custom component through hacs.
i was able to find the token but i can’t see it among the home assistant entities?
what should the entity be called?
my model is samsung JU7500

@sermayoral - thanks for the work you’ve put in on this. I too have a H6400. I’m getting close to getting the authorisation but am getting this error in Python. Any idea how to get past this please?

ImportError: bad magic number in ‘PySmartCrypto.crypto’: b’\x03\xf3\r\n’

UPDATE:

I’ve got past this now. I found my python3 installation folder in appdata folder and changed the cryto folder to Crypto as per various other posts.

Then I opened \homeassistant\config\custom_components\samsungtv_encrypted\ in powershell by holding ctrl+right shift+right-click and selecting ‘Open in PowerShell window here’. (samba share has to be set up to do this in Windows)

This time when I ran “python3 get_token.py --ip 192.168.x.x --port 8080” the code popped up on screen and I was able to continue the process.

This created a media_player.samsung_tv_remote entity that I was able to open up in a card on my dashboard.

Next step is getting the send code functions to work so I can do more than just change the volume and power the TV off.

@sermayoral Thanks for all your efforts here. I have managed to get this working for my H6400 apart from turning on the TV. From your GitHub page you suggest using the following into configuration.yaml

- platform: samsungtv_encrypted
  ...
  turn_on_action:
    - service: kodi.call_method
      data:
        entity_id: media_player.kodi
        method: Addons.ExecuteAddon
        addonid: script.json-cec
        params:
          command: turn_on 0

I have done that, but there appears to be a dependency on Kodi. Tried adding as an integration but couldn’t get this to work as relies on HTTP service running. Tried using the homeassistant IP address but that didn’t work. Any ideas on how to get this working?

That is an example. You need some other thing to turn on the TV through HDMI CEC or IR. HA used to have the HDMI CEC way, but has been removed a few version back due to some issue with it. So the HDMI branch of this integration has been removed as well.

You best option is to have an IR device (Harmony, Broadlink) or an Android TV device connected through HDMI to the TV to turn it on.

Thanks @GSzabados. Makes sense. Do you know if HDMI CEC will be added back into HA at some point in the future? I have both Harmony and Broadlink but was trying to avoid the IR route.

Do you know if a Fire TV stick would work for the Android device connected through HDMI, as I understand this is built on Android or are you referring to something like Chromecast?

1 Like

@andypburke, I used to use a Xiaomi Mi Box 3 (Android TV), but unfortunately the latest Android Pie update rendered the aforementioned feature useless.

If your Fire TV stick is not powered from the TV’s USB port, then you have a good chance. Can you turn on the TV by using the remote of the Fire TV stick? Can you turn on the TV by asking Alexa/Google to turn on the Fire TV stick? Do you have the Fire TV stick as an entity in HA? If yes, then you have a good chance to turn it on.

turn_on_action:
    - service: media_player.turn_on
      data:
        entity_id: media_player.mibox3

Thanks again for your help @GSzabados. My fire TV stick can turn the TV on using the remote control, although I haven’t got FireTV as an entity setup as I am still finding my way around how to config HA manually (just used discovered integrations so far).

I have found this on how to setup Android TV (including FireTV), but not sure if I need all of this to be able to turn the Samsung TV on. https://www.home-assistant.io/integrations/androidtv/#adb-setup

Any advice on how to configure the Fire TV to turn the Samsung TV on as part of the Remote add on?

Sorry, I don’t have any FireTV or Amazon Alexa products, so I cannot help with that. My Mi Box was recognized automatically by HA.

Set up the Android TV integration for the Fire TV, it has a lot of features, what can be really useful. Like state of the Android TV, playing or pause, you can build automations on that for lights for a movie night. :wink:

Dears all,

I tested with a UE55JU7500 and don’t works. I configured the get_token, and then intregate the media player with the token, etc. I can see the card, but when I want to change the volumn appers some text in the TV but the volumen dont’ changues. Then this integration for my JU7500 don’t works well. Any Solution?

@sermayoral, is there any way to automate the Speaker Select? I would like to set the Speaker Select option to Receiver.