Samsung Smart TV Integration not working

Tags: #<Tag:0x00007fc40591e350>

Hi! I am trying to set up samsungtv integration in config with turn_on_action, but I get “Error while setting up samsungtv platform for media_player”.

When I remove turn_on_action seems to work.

Config

wake_on_lan:

samsungtv:
  host: xxx.xxx.xxx.xxx
  name: TV
  turn_on_action:
    service: wake_on_lan.send_magic_packet
    data:
      mac: 'AA:BB:CC:DD:EE:FF'
      broadcast_address: xxx.xxx.xxx.xxx
      broadcast_port: 9

Logs / traceback

Logger: homeassistant.components.media_player
Source: util/__init__.py:47
Integration: Odtwarzacz mediów (documentation, issues)
First occurred: 17:09:38 (1 occurrences)
Last logged: 17:09:38

Error while setting up samsungtv platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/samsungtv/media_player.py", line 73, in async_setup_entry
    on_script = Script(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 818, in __init__
    self._set_logger(logger)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 858, in _set_logger
    self._logger = logging.getLogger(f"{__name__}.{slugify(self.name)}")
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 47, in slugify
    return unicode_slug.slugify(text, separator=separator)
  File "/usr/local/lib/python3.8/site-packages/slugify/slugify.py", line 104, in slugify
    text = _unicode(text, 'utf-8', 'ignore')
TypeError: decoding to str: need a bytes-like object, NoneType found

Hi,
I got something similar with the slugify.py but int the Mikrotik Device Tracker.
Looks similar and I could not find the exact issue.
it seems that something does not have the right type.

Logger: homeassistant.components.device_tracker
Source: util/__init__.py:92
Integration: Device tracker (documentation, issues)
First occurred: 3:59:32 PM (2 occurrences)
Last logged: 3:59:32 PM

Error adding entities for domain device_tracker with platform mikrotik
Error while setting up mikrotik platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 315, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 412, in _async_add_entity
    entry = entity_registry.async_get_or_create(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 243, in async_get_or_create
    entity_id = self.async_generate_entity_id(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 176, in async_generate_entity_id
    preferred_string = f"{domain}.{slugify(suggested_object_id)}"
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 92, in slugify
    slug = unicode_slug.slugify(text, separator=separator)
  File "/usr/local/lib/python3.8/site-packages/slugify/slugify.py", line 104, in slugify
    text = _unicode(text, 'utf-8', 'ignore')
TypeError: decoding to str: need a bytes-like object, int found

On my case the

suggested_object_id

is not a bytes object. I do not know what does this means.

On your case is the:

self.name

that is causing this issue. Does the name contains characters that cannot be utf-8 encoded?

Hi, just came across the same issue and fixed it by editting file

config/.storage/core.config_entries

Previously name was null, set it to some reasonable value:

            {
                ...
                "domain": "samsungtv",
                "data": {
                    ...
                    "name": "Samsung TV",
                    ...
                },
                ...
            }

Hope it helps

1 Like

Hi, does anyone ever get the wake on LAN work for the TV? For me it didn’t do anything.

@_LoOp I see that you set broadcast_port to 9, from where did you get this port number?
Thanks!

I believe that setting broadcast_port is not necessary, it depends on your TV. I solved the issue with some workaround by doing template for media player. I combined TV media player entity from UI Samsung TV integration setup with Wake on LAN switch into one media player with all what I needed. :smiley: