Core: Samsung TV's not working [Testing fix]

Created on 6 Feb 2019  ·  374Comments  ·  Source: home-assistant/core

*****UPDATED*****
PLEASE READ ALL THE INFORMATION BELOW THERE ARE PARTS THAT HAVE CHANGED

I am moving the conversation that is taking place in #17802 as the current conversation really has nothing to do with the issue that was reported.

If this is not OK then delete this issue. I am the person that is currently updating the code to samsungctl. It has undergone a lot of additions which I do believe the users of Home Assistant will enjoy being able to use.

thee library also now supports ALL Samsung TV's that have the capability of being controlled over a network or WiFi Connection from 2008 to present. This includes the encrypted websocket connections (H (2014) and J (2015) TV's) as well as the SSL websocket connection (latest firmware release).

I have simplified the connection process so that the only things that are needed in thee Home Assistant config file is the host (ip) of the TV. nothing else is needed. the samsungctl library now handles hammering all of the connection specific details. I also added to it a a class that handles loading and saving of config data. I did this to handle the dynamically changing tokens that are used with the encrypted websockets and SSL websockets. the library now also does not stop running if the connection get severed.. (TV gets powered off). I also changed the handling of the power keys to make them function like they should. KEY_POWER = power toggle, KEY_POWERON = power on and KEY_POWEROFF = power off.

I am currently testing the replacement for /homeassistant/components/media_player/samsungtv.py, because I am not familiar with Home Assistant it is better to hammer these problems out in an issue where they can be tested then to open a PR for non functioning code and end up with a very messy commit history.

PLEASE READ

This is a replacement for the /homeassistant/components/media_player/samsungtv.py file
please do not edit the code and then report an issue. only report problems relating to this code. also do not provide vague errors. like it says config error.. I am willing to bet the error stats more then "config error". I need a copy of the error message in it's entirety. not little bits and pieces. because of the nature of Home Assistant you may need to scroll back in the logs and read for a bit to make sure that you have grabbed all of the relevant log messages.

If you state anything about "custom_components" or if i see that in any of the errors I am not going to answer you. this is because you have modified the code. and it is a pretty good chance that your modification is what is causing the problem.

If you do not do the above then I have no way of helping to solve any issues.

config files for the TV are going to be saved in a directory called samsung_tv that is located in the Home Assistant config folder. the config files for the TVs are going to be named using the IP address you supply in the Home Assistant config yaml file.

HOME ASSISTANT CONFIG FILE
This is the only thing that needs to be added to your hass configuration.yaml file. you will not need to specify any kind of a host. or mac or name. nothing. The whole system will dynamically add TV's as it finds them (of coarse with your permission). if a TV is found you will get a notification in the hass UI. when you open this notification you will be prompted to change the display name, the mac address and the description. if you do not wish to change them simply click on the accept button. You may need to refresh the page once the device is added for it to show up. If you have more then a single TV you DO NOT need to add multiple entries into the hass config file. You only need to add the below code a single time.

If you do not want to add a TV to hass (not sure why you wouldn't) simply ignore the notification. it will disappear after 60 seconds. if you change your mind afterwards or you simply miss the timeout you will need to go into thee samsung_tv config directory and delete the file that has an extension of .noinclude.

media_player:
  - platform: samsungtv

the config file will only get saved once there is a successful connection to the TV made. I have changed about the detection mechanism for the 4 different types of connections. I am hoping this is going to be more of a dock solid mechanism of detecting the connection type. IF you have an issue detecting your TV let me know. There are some tasks I will have you do in order to get it to detect the TV properly. I do not own every Samsung TV made so there is no way to test it on my end. so it is up to you guys to follow the bug reporting directions as outline above.

Here is the updated code.

I WILL NOT MAKE CHANGES AND MAKE ANOTHER POST FOR IT. I WILL UPDATE THE CODE BELOW WITH ANY NEW CHANGES AND INFORM YOU THAT THE CODE HAS CHANGED

click to expand

"""
Support for interface with an Samsung TV.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.samsungtv/
"""
import asyncio
from datetime import timedelta
import logging
import threading
import os
import uuid

import voluptuous as vol

from homeassistant.components.media_player import (
    MEDIA_TYPE_CHANNEL, PLATFORM_SCHEMA, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
    SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_TURN_OFF,
    SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
    SUPPORT_VOLUME_SET, SUPPORT_SELECT_SOURCE, MediaPlayerDevice)
from homeassistant.const import (
    CONF_NAME,
    STATE_OFF,
    STATE_ON
)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import dt as dt_util


REQUIREMENTS = [
     'https://github.com/kdschlosser/'
     'samsungctl/archive/develop.zip#samsungctl==0.8.64b'
]

SAMSUNG_CONFIG_PATH = 'samsung_tv'

ICON_TV = 'mdi:television'
ICON_TV_OFF = 'mdi:television-off'
ICON_COMPONENT = 'mdi:video-input-component'
ICON_HDMI = 'mdi:video-input-hdmi'
ICON_SVIDEO = 'mdi:video-input-svideo'
ICON_USB = 'mdi:usb'
ICON_PC = 'mdi:console'
ICON_DLNA = 'mdi:dlna'
ICON_AV = 'mdi:audio-video'
ICON_YOUTUBE = 'mdi:youtube'
ICON_HULU = 'mdi:hulu'
ICON_NETFLIX = 'mdi:netflix'
ICON_PLEX = 'mdi:plex'
ICON_SPOTIFY = 'mdi:spotify'
ICON_AMAZON = 'mdi:amazon'
ICON_PLAYSTATION = 'mdi:playstation'
ICON_UNKNOWN = 'mdi:help'

_LOGGER = logging.getLogger(__name__)

CONF_DESCRIPTION = 'description'
CONF_ADD = 'add_tv'

KEY_PRESS_TIMEOUT = 1.2
KNOWN_DEVICES_KEY = 'samsungtv_known_devices'

SUPPORT_SAMSUNGTV = (
    SUPPORT_PAUSE |
    SUPPORT_VOLUME_STEP |
    SUPPORT_VOLUME_MUTE |
    SUPPORT_PREVIOUS_TRACK |
    SUPPORT_NEXT_TRACK |
    SUPPORT_TURN_OFF |
    SUPPORT_PLAY |
    SUPPORT_PLAY_MEDIA |
    SUPPORT_VOLUME_SET |
    SUPPORT_SELECT_SOURCE
)


SAMSUNG_TV_SCHEMA = vol.Schema({
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(CONF_DESCRIPTION): cv.string,
    vol.Optional(CONF_ADD): cv.boolean,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({})

_CONFIGURING = {}


def setup_platform(hass, config, add_entities, _=None):
    """Set up the Samsung TV platform."""

    config_path = hass.config.path(SAMSUNG_CONFIG_PATH)

    if not os.path.exists(config_path):
        os.mkdir(config_path)

    known_devices = hass.data.get(KNOWN_DEVICES_KEY, set())
    hass.data[KNOWN_DEVICES_KEY] = known_devices

    import samsungctl
    from samsungctl.upnp.discover import auto_discover

    config_files = list(
        os.path.join(config_path, file) for file in os.listdir(config_path)
            if file.endswith('config')
    )

    def callback(found_config):
        if found_config.uuid in known_devices:
            return

        _LOGGER.debug(str(found_config))
        known_devices.add(found_config.uuid)

        no_include = os.path.join(
            config_path,
            found_config.uuid + '.noinclude'
        )

        if os.path.exists(no_include):
            return

        if found_config.uuid not in _CONFIGURING:
            add_device(found_config, hass, config_path, add_entities)

    auto_discover.register_callback(callback)
    entities = []
    configs = []

    for config_file in config_files:
        _LOGGER.debug(config_file)
        samsung_config = samsungctl.Config.load(config_file)
        known_devices.add(samsung_config.uuid)
        configs += [samsung_config]

    auto_discover.start()

    for samsung_config in configs:
        entities += [SamsungTVDevice(samsung_config)]
    add_entities(entities)


def add_device(samsung_config, hass, config_path, add_entities):
    model = samsung_config.model
    uuid = samsung_config.uuid

    event = threading.Event()

    def samsung_configuration_callback(data):
        """Handle the entry of user PIN."""
        display_name = data.get('display_name')
        description = data.get('description')
        mac = data.get('mac')

        if display_name is None:
            display_name = samsung_config.display_name
        if description is None:
            description = samsung_config.description
        if mac is None:
            mac = samsung_config.mac

        samsung_config.display_name = display_name
        samsung_config.description = description
        samsung_config.mac = mac

        samsung_config.path = os.path.join(
            config_path,
            samsung_config.uuid + '.config'
        )

        hass.components.configurator.request_done(_CONFIGURING.pop(uuid))

        if samsung_config.method == 'encrypted':
            request_configuration(samsung_config, hass, add_entities)
        else:
            add_entities([SamsungTVDevice(samsung_config)])

        event.set()

    def do():
        event.wait(600.0)
        if not event.isSet():
            path = os.path.join(
                config_path,
                samsung_config.uuid + '.noinclude'
            )

            with open(path, 'w') as f:
                f.write('')

            hass.components.configurator.request_done(_CONFIGURING.pop(uuid))

    t = threading.Thread(target=do)
    t.daemon = True
    t.start()

    _CONFIGURING[uuid] = hass.components.configurator.request_config(
        model,
        samsung_configuration_callback,
        description='New TV discovered, would you like to add the TV?',
        description_image="/static/images/smart-tv.png",
        submit_caption="Accept",
        fields=[
            dict(
                id='display_name',
                name='Name: ' + samsung_config.display_name,
                type=''
            ),
            dict(
                id='description',
                name='Description: ' + samsung_config.description,
                type=''
            ),
            dict(
                id='mac',
                name='MAC Address : ' + str(samsung_config.mac),
                type=''
            )
        ]
    )


def request_configuration(samsung_config, hass, add_entities):
    """Request configuration steps from the user."""

    configurator = hass.components.configurator

    import samsungctl

    pin = []
    count = 0
    event = threading.Event()

    def samsung_configuration_callback(data):
        """Handle the entry of user PIN."""
        pin.append(data.get('pin'))
        event.set()

    def get_pin():
        global count

        if samsung_config.uuid in _CONFIGURING:
            count += 1
            event.clear()
            del pin[:]

            configurator.notify_errors(
                _CONFIGURING[samsung_config.uuid],
                "Failed to register, please try again."
            )
        else:
            _CONFIGURING[samsung_config.uuid] = configurator.request_config(
                samsung_config.display_name,
                samsung_configuration_callback,
                description='Enter the Pin shown on your Samsung TV.',
                description_image="/static/images/smart-tv.png",
                submit_caption="Confirm",
                fields=[{'id': 'pin', 'name': 'Enter the pin', 'type': ''}]
            )

        event.wait(60.0)

        if count == 3:
            _LOGGER.error(
                samsung_config.display_name + " TV: Pin entry failed"
            )
            return False
        elif not event.isSet():
            return None

        return pin[0]

    samsung_config.get_pin = get_pin

    def do():
        global count

        try:
            _ = samsungctl.Remote(samsung_config)
            add_entities([SamsungTVDevice(samsung_config)])
        except:
            pass

        hass.components.configurator.request_done(_CONFIGURING.pop(uuid))

    t = threading.Thread(target=do)
    t.daemon = True
    t.start()


class SamsungTVDevice(MediaPlayerDevice):
    """Representation of a Samsung TV."""

    def __init__(self, config):
        """Initialize the Samsung device."""
        from samsungctl import exceptions
        from samsungctl import Remote

        # Save a reference to the imported classes
        self._exceptions_class = exceptions
        self._remote_class = Remote
        self._config = config
        self._mac = self._config.mac
        self._uuid = self._config.uuid
        self._playing = True
        self._state = None
        self._remote = None
        self._key_source = False
        self._mute = False
        self._sources = []
        self._source = ''
        self._volume = 0.0
        self._entity_image = None
        self._tv_image = None

        if self._config.method == 'websocket':
            self._has_apps = True
        else:
            self._has_apps = False
        self._icon = ICON_TV_OFF

        self._supported_features = SUPPORT_SAMSUNGTV
        if self._config.method != 'legacy':
            self._supported_features |= SUPPORT_TURN_ON

        # Mark the end of a shutdown command (need to wait 15 seconds before
        # sending the next command to avoid turning the TV back ON).
        self._end_of_power_off = None

        # Mark the end of the TV powering on.need to wait 20 seconds before
        # sending any commands.
        self._end_of_power_on = None
        # Generate a configuration for the Samsung library

        self._remote = self._remote_class(self._config)

    def update(self):
        """Update state of device."""
        if self._power_off_in_progress():
            _LOGGER.debug(
                self._config.display_name + ' TV: Powering Off'
            )
            self._state = STATE_OFF
            self._icon = ICON_TV_OFF
            # self._entity_image = self._tv_image

        elif self._power_on_in_progress():
            _LOGGER.debug(
                self._config.display_name + ' TV: Powering On'
            )
            self._state = STATE_OFF
            self._icon = ICON_TV_OFF
            # self._entity_image = self._tv_image
        else:
            power = self._remote.power
            if power is True and self._remote.is_connected:
                self._config.save()

                if self._tv_image is None:
                    tv_image = self._remote.icon
                    if tv_image is not None:
                        self._tv_image = tv_image.data
                sources = self._remote.sources
                entity_image = self._tv_image
                source = 'Unknown'

                if sources is None:
                    if self._has_apps:
                        sources = [
                            'TV',
                            'HDMI'
                        ]

                        for app in self._remote.applications:

                            if app.is_running and app.is_visible:
                                source = 'APP: ' +app.name
                                entity_image = app.icon

                            sources += ['APP: ' + app.name]

                        self._sources = sources
                        self._source = source
                        self._entity_image = entity_image
                    else:
                        self._sources = [
                            'Source',
                            'Component 1',
                            'Component 2',
                            'AV 1',
                            'AV 2',
                            'AV 3',
                            'S Video 1',
                            'S Video 2',
                            'S Video 3',
                            'HDMI',
                            'HDMI 1',
                            'HDMI 2',
                            'HDMI 3',
                            'HDMI 4',
                            'FM-Radio',
                            'DVI',
                            'DVR',
                            'TV',
                            'Analog TV',
                            'Digital TV'
                        ]
                        self._key_source = True
                else:
                    new_sources = []
                    for src in sources:
                        if src.is_active:
                            if src.label != src.name:
                                source = src.label + ':' + src.name
                            else:
                                source = src.name

                        if src.name != src.label:
                            new_sources += [src.label + ':' + src.name]
                        else:
                            new_sources += [src.name]

                    self._key_source = False
                    self._sources = new_sources[:]

                self._source = source
                # self._entity_image = entity_image

                if self._source.upper().endswith('TV'):
                    self._icon = ICON_TV
                elif self._source.upper().endswith('USB'):
                    self._icon = ICON_USB
                elif self._source.upper().endswith('PC'):
                    self._icon = ICON_PC
                elif self._source.upper().endswith('DLNA'):
                    self._icon = ICON_DLNA

                elif 'S VIDEO' in self._source.upper():
                    self._icon = ICON_SVIDEO
                elif 'COMPONENT' in self._source.upper():
                    self._icon = ICON_COMPONENT
                elif 'AV' in self._source.upper():
                    self._icon = ICON_AV
                elif 'HDMI' in self._source.upper():
                    self._icon = ICON_HDMI
                elif 'YOUTUBE' in self._source.upper():
                    self._icon = ICON_YOUTUBE
                elif 'HULU' in self._source.upper():
                    self._icon = ICON_HULU
                elif 'NETFLIX' in self._source.upper():
                    self._icon = ICON_NETFLIX
                elif 'PLEX' in self._source.upper():
                    self._icon = ICON_PLEX
                elif 'SPOTIFY' in self._source.upper():
                    self._icon = ICON_SPOTIFY
                elif 'AMAZON' in self._source.upper():
                    self._icon = ICON_AMAZON
                elif 'PLAYSTATION' in self._source.upper():
                    self._icon = ICON_PLAYSTATION
                else:
                    self._icon = ICON_UNKNOWN

                volume = self._remote.volume
                _LOGGER.debug(
                    self._config.display_name + ' TV: Volume = ' + str(volume)
                )
                if volume is not None:
                    self._volume = volume / 100.0

                mute = self._remote.mute
                _LOGGER.debug(
                    self._config.display_name + ' TV: Mute = ' + str(mute)
                )
                if mute is None:
                    self._mute = False
                else:
                    self._mute = mute

                _LOGGER.debug(
                    self._config.display_name + ' TV: Power is On'
                )
                self._state = STATE_ON
            else:
                _LOGGER.debug(
                    self._config.display_name + ' TV: Power is Off'
                )
                # self._entity_image = self._tv_image
                self._icon = ICON_TV_OFF
                self._state = STATE_OFF

    def send_key(self, key):
        """Send a key to the tv and handles exceptions."""
        if self._power_off_in_progress():
            _LOGGER.info(
                self._config.display_name +
                " TV: powering off, not sending command: %s",
                key
            )
            return

        elif self._power_on_in_progress():
            _LOGGER.info(
                self._config.display_name +
                " TV: powering on, not sending command: %s",
                key
            )
            return

        if self._state == STATE_OFF:
            _LOGGER.info(
                self._config.display_name +
                " TV: powered off, not sending command: %s",
                key
            )
            return

        self._remote.control(key)

    @property
    def icon(self):
        """Return the icon to use in the frontend, if any."""
        return self._icon

    @property
    def entity_picture(self):
        """Return the entity picture to use in the frontend, if any."""
        return self._entity_image

    @property
    def unique_id(self) -> str:
        """Return the unique ID of the device."""
        return '{' + self._config.uuid + '}'

    @property
    def name(self):
        """Return the name of the device."""
        return self._config.display_name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def supported_features(self):
        """Flag media player features that are supported."""
        return self._supported_features

    def select_source(self, source):
        """Select input source."""
        if self._key_source:
            if source == 'Analog TV':
                source = 'ANTENA'

            elif source == 'Digital TV':
                source = 'DTV'

            source = source.upper().replace('-', '_').replace(' ', '')
            source = 'KEY_' + source
            _LOGGER.debug(
                self._config.display_name + ' TV: changing source to ' + source
            )
            self.send_key(source)
        else:
            if 'APP' in source:
                app_name = source.rsplit(':', 1)[-1]
                app = self._remote.get_application(app_name)

                if app is not None:
                    app.run()

            if ':' in source:
                source = source.rsplit(':', 1)[-1]
            _LOGGER.debug(
                self._config.display_name + ' TV: changing source to ' + source
            )
            self._remote.source = source

    @property
    def source(self):
        """Name of the current input source."""
        return self._source

    @property
    def source_list(self):
        """List of available input sources."""
        return self._sources

    def volume_up(self):
        """Volume up the media player."""
        self.send_key('KEY_VOLUP')

    def volume_down(self):
        """Volume down media player."""
        self.send_key('KEY_VOLDOWN')

    @property
    def volume_level(self):
        """Volume level of the media player scalar volume. 0.0-1.0."""
        return self._volume

    def set_volume_level(self, volume):
        """Set volume level, convert scalar volume. 0.0-1.0 to percent 0-100"""
        self._remote.volume = int(volume * 100)

    def mute_volume(self, mute):
        """Send mute command."""
        self._remote.mute = mute

    @property
    def is_volume_muted(self):
        """Boolean if volume is currently muted."""
        return self._mute

    def media_play_pause(self):
        """Simulate play pause media player."""
        if self._playing:
            self.media_pause()
        else:
            self.media_play()

    def media_play(self):
        """Send play command."""
        self._playing = True
        self.send_key('KEY_PLAY')

    def media_pause(self):
        """Send media pause command to media player."""
        self._playing = False
        self.send_key('KEY_PAUSE')

    def media_next_track(self):
        """Send next track command."""
        self.send_key('KEY_FF')

    def media_previous_track(self):
        """Send the previous track command."""
        self.send_key('KEY_REWIND')

    async def async_play_media(self, media_type, media_id, **kwargs):
        """Support changing a channel."""
        if media_type != MEDIA_TYPE_CHANNEL:
            _LOGGER.error(
                self._config.display_name + ' TV: Unsupported media type'
            )
            return

        # media_id should only be a channel number
        try:
            cv.positive_int(media_id)
        except vol.Invalid:
            _LOGGER.error(
                self._config.display_name +
                ' TV: Media ID must be positive integer'
            )
            return

        for digit in media_id:
            await self.hass.async_add_job(self.send_key, 'KEY_' + digit)
            await asyncio.sleep(KEY_PRESS_TIMEOUT, self.hass.loop)

    @property
    def app_id(self):
        """ID of the current running app."""
        return None

    @property
    def app_name(self):
        """Name of the current running app."""
        return None

    def turn_on(self):
        """Turn the media player on."""

        if self._power_on_in_progress():
            return

        if self._config.mac:
            self._end_of_power_on = dt_util.utcnow() + timedelta(seconds=20)

            if self._power_off_in_progress():
                self._end_of_power_on += (
                    dt_util.utcnow() - self._end_of_power_off
                )

            def do():
                _LOGGER.debug(
                    self._config.display_name + ' TV: Power on process started'
                )
                event = threading.Event()
                while self._power_off_in_progress():
                    event.wait(0.5)

                self._remote.power = True

            t = threading.Thread(target=do)
            t.daemon = True
            t.start()
        elif self._config.method != 'legacy':
            _LOGGER.info(
                self._config.display_name +
                " TV: There was a problem detecting the TV's MAC address, "
                "you will have to update the MAC address in the Home "
                "Assistant config file manually."
            )

        else:
            _LOGGER.info(
                self._config.display_name +
                " TV: Legacy TV's (2008 - 2013) do not support "
                "being powered on remotely."
            )

    def _power_on_in_progress(self):
        return (
            self._end_of_power_on is not None and
            self._end_of_power_on > dt_util.utcnow()
        )

    def turn_off(self):
        """Turn off media player."""

        if self._power_off_in_progress():
            return

        self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)

        if self._power_on_in_progress():
            self._end_of_power_off += (
                dt_util.utcnow() - self._end_of_power_on
            )

        def do():
            _LOGGER.debug(
                self._config.display_name + ' TV: Power off process started'
            )
            event = threading.Event()
            while self._power_on_in_progress():
                event.wait(0.5)

            self._remote.power = False

        t = threading.Thread(target=do)
        t.daemon = True
        t.start()

    def _power_off_in_progress(self):
        return (
            self._end_of_power_off is not None and
            self._end_of_power_off > dt_util.utcnow()
        )

samsungtv

Most helpful comment

After HA updates, I have decided to create a custom component, it is working on the latest version of HA 0.99.3, I have uploaded the code to:

https://github.com/roberodin/ha-samsungtv-custom

I hope it helps you.

All 374 comments

There is a missing , after the line vol.Optional(CONF_METHOD): cv.string. After adding the comma, I am getting the following error:

Log Details (ERROR)
Wed Feb 06 2019 15:01:28 GMT-0500 (Eastern Standard Time)
Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/samsungtv.py", line 109, in setup_platform
    [SamsungTVDevice(host, name, description, method, uuid, config_path)]
  File "/config/custom_components/media_player/samsungtv.py", line 136, in __init__
    self._config = samsungctl.Config()
  File "/config/deps/lib/python3.6/site-packages/samsungctl/config.py", line 57, in __init__
    raise exceptions.ConfigHostError
samsungctl.exceptions.ConfigHostError: <unprintable ConfigHostError object>

My TV is UN75NU8000.

I updated the code in the first post to solve both problems.

UPNP errors now:

Log Details (ERROR)
Wed Feb 06 2019 15:13:35 GMT-0500 (Eastern Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 302, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 1215, in volume
    if not self.connected:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 30, in connected
    self._connect_upnp()
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 37, in _connect_upnp
    if not self._connected and self.power:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  [Previous line repeated 322 more times]
RecursionError: maximum recursion depth exceeded

Are you on Home Assistant Discord?

Are you on Home Assistant Discord?

dunno what that is.

can you do me a favor. please attach this file to a post. samsungctl/upnp/__init__.py

Discord has Home Assistant chat server, easy to coordinate https://www.home-assistant.io/help/

Here's the Discord server link: https://discord.gg/6JJ3Rb

Nevermind on that last post.

I am not trying to be rude at all. but I can see you did not follow my directions.
This is the reason why I cannot stress enough to FOLLOW DIRECTIONS

it clearly states in the first post.

DO THIS FIRST

we are going to want to clean out any installed versions of the current samsungctl library. you can do this from a command prompt (shell)

pip uninstall samsungctl

I have updated some code of the code in samsungctl and the new code needs to be downloaded. and installed. I really would prefer if you also installed it from the command line using

pip install --no-cache-dir "https://github.com/kdschlosser/samsungctl/archive/develop.zip#samsungctl==0.8.0b"

this will make sure it gets installed without using a cached copy of it that may be on your system

You have an old copy of samsungctl that is being used. that is why you are getting the error.

Let me reinstall Hassio afresh and test it out again. Gimme 10 min.

Ok....started afresh and now I see the entity created :tada:

I have not tested anything yet. But I see the media_player entity, which is huge progress :)

I am going nutz over here trying to locate the problem. and i have not been able to come up with anything. I even coded up a replica of the process that is taking place and it runs fine.

you got me on this one. But it appears as tho you have has some progress. and there was possibly something latent kicking about somewhere causing the issue.

I think there is definitely something wrong here. After restarting I am getting the same UPNP errors.

Log Details (ERROR)
Wed Feb 06 2019 16:58:13 GMT-0500 (Eastern Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 258, in source
    source = self.get_remote().source
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 950, in source
    if not self.connected:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 30, in connected
    self._connect_upnp()
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 37, in _connect_upnp
    if not self._connected and self.power:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  [Previous line repeated 322 more times]
RecursionError: maximum recursion depth exceeded

Not sure if this may be causing it, but I am using a Sonos Playbase for audio. I know it is frustrating

here is what I am going to do. I will bump the version on the develop branch and update the code in the first post to use the new version.

ok I did the version bump.

So, unfortunately, the same issue, it worked after I put the code in for the first time. But after restarting HA, I get the same UPNP errors:

Log Details (ERROR)
Wed Feb 06 2019 15:47:31 GMT-0500 (Eastern Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 302, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 1215, in volume
    if not self.connected:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 30, in connected
    self._connect_upnp()
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 37, in _connect_upnp
    if not self._connected and self.power:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  [Previous line repeated 323 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

If you are on Discord (https://discord.gg/6JJ3Rb) it will be easier to debug. I am at home and can work on it in real-time.

my question is what is happening when you restart.. the code that is getting loaded is changing somehow

I do not know anything about your setup. but is there a possibility of some old copy of samsungctl kicking about in some other python installations site-packags folder?.

as an example. with another project that i work on. it uses python 2.7 but it is all set up as an executable. so technically speaking there is no python installation when you install it. But. if you install python 2.7 my program will load the site-packages directory from that python installation.

Now the reason why it works right after installation is because the neew version gets plopped in the begining of the search order. once you restart the program it is no longer going to be at the beginning of that search order.

I have also run into issues because of mixes installation types. example.

if you run python setup.py install it will install the library but you get either a file or a folder name that ends with .egg but if you do the install using pip that is not the case. the wacky thing is if you install via pip after you have already installed using python setup.py install you will end up with 2 installations.. and pip gets all mucked up when removing it.

it's a strange thing.

I am going to add some information printouts. like the location of the library and the version.

OK i updated the code in the first post to give us a printout of what is going on.

Here you go (had to change to error as info is not logged by default):

2019-02-07 03:14:30 ERROR (SyncWorker_7) [custom_components.media_player.samsungtv] samsungctl version: 0.8.1b
2019-02-07 03:14:30 ERROR (SyncWorker_7) [custom_components.media_player.samsungtv] samsungctl location: /config/deps/lib/python3.6/site-packages/samsungctl
2019-02-07 03:14:30 ERROR (SyncWorker_7) [custom_components.media_player.samsungtv] Samsung TV 192.168.2.252 added as 'Living Room TV'
2019-02-07 03:14:31 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 1215, in volume
    if not self.connected:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 30, in connected
    self._connect_upnp()
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/__init__.py", line 37, in _connect_upnp
    if not self._connected and self.power:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 123, in __getattr__
    if item in self._devices:
  [Previous line repeated 322 more times]
RecursionError: maximum recursion depth exceeded

That is the whole log - I did not modify anything. The custom_component is how you test stuff in HA when it is not officially implemented, which is the case here.

What are you looking for specifically? My guess is once the entity is added, it tries to get all the properties and that is where the error appears.

Is there a way to eliminate UPNP (for now) to make sure that the basic media player works?

give it a try again. delete samsungctl first. I updated the code in my repository

019-02-07 03:30:18 ERROR (SyncWorker_2) [custom_components.media_player.samsungtv] samsungctl version: 0.8.1b
2019-02-07 03:30:18 ERROR (SyncWorker_2) [custom_components.media_player.samsungtv] samsungctl location: /config/deps/lib/python3.6/site-packages/samsungctl
2019-02-07 03:30:18 ERROR (SyncWorker_2) [custom_components.media_player.samsungtv] Samsung TV 192.168.2.252 added as 'Living Room TV'
2019-02-07 03:30:19 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: volume
2019-02-07 03:30:30 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: volume
2019-02-07 03:30:41 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: volume
2019-02-07 03:30:52 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: volume
2019-02-07 03:31:03 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: volume

Just for kicks, I removed all the volume and source related code from the component and it kinda works now. The state is still messed up, but no errors.

do me a favor. do not modify this one. try it first. so you ar going to have to return the changes you made back to the way they were.

I updated the develop branch of samsungctl. give it a go and see how you make out.

Slightly different error this time, but still not working.

2019-02-07 13:08:30 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 305, in volume_level
    volume = self.get_remote().volume
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: volume

Wondering if there is no value for volume = self.get_remote().volume when using a soundbar/receiver. Maybe guard against that.

Okay, just a minor thing and not important for now at all, but I was setting everything up and I noticed the error below, it is just something to beautify the code:

The TV is not connected to the network (not at home now so can't investigate why it isn't), but I was doing some preparation work for later today

So I got this error (which is correct):

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/samsungctl/remote_legacy.py", line 84, in open
    self.sock.connect((self.config.host, self.config.port))
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 232, in async_update_ha_state
    state = self.state
  File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 224, in state
    power = self.get_remote().power
  File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 178, in get_remote
    self._remote.open()
  File "/usr/local/lib/python3.6/site-packages/samsungctl/utils.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/samsungctl/remote_legacy.py", line 87, in open
    raise RuntimeError('Unable to pair with TV.. Is the TV on?!?')
RuntimeError: Unable to pair with TV.. Is the TV on?!?

But then it continues and gives this error every ~10 sec:

Update for media_player.living_room_tv fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 167, in update
    power = self.get_remote().power
  File "/usr/local/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 131, in __getattr__
    return self.__class__.__dict__[item].fget(self)
  File "/usr/local/lib/python3.6/site-packages/samsungctl/utils.py", line 44, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/samsungctl/remote_legacy.py", line 45, in power
    self.sock.self.sock.setblocking(0)
AttributeError: 'socket' object has no attribute 'self'

Perhaps you can enhance to code to check if the socket is actually open before trying to do something with it?

@kdschlosser Also, see https://github.com/home-assistant/home-assistant/issues/4210 for the I/O issues. We are doing a lot of I/O inside properties, which should be avoided.

So, I modified one of the properties to:

    @property
    def volume_level(self):
        """Volume level of the media player scalar volume. 0.0-1.0."""
        try:
            volume = self.get_remote().volume
            if volume is None:
                volume = 0.0
            else:
                volume /= 100.0
        except: # we should catch the specific error
            volume = 0.0
            _LOGGER.error('No Volume returned')
        return volume

and now I get a lot of No Volume returned in the logs but not the same UPNP error. The error that I get now is about a different property (one that was not fixed):

Log Details (ERROR)
Thu Feb 07 2019 10:08:03 GMT-0500 (Eastern Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 787, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "/config/custom_components/media_player/samsungtv.py", line 327, in is_volume_muted
    return False if not self.get_remote().mute else True
  File "/config/deps/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 133, in __getattr__
    raise AttributeError(item)
AttributeError: mute

This basically tells me that error handling has to be improved. We obviously should catch the specific error (instead of using a simple except:).

The state still does not update. The entity kept reporting off even when the TV was on

So, I tried to update the component code to remove the I/O from properties and here is a very crude attempt - code. It needs to be massively cleaned up and state update have to be fixed, but it is kind of working.

On the state, it looks like self.get_remote().power does not report the right state. In my case, it kept reporting False even when the TV was on.

this error is a fat finger and is for older samsung TV's it is easily repairable.

Update for media_player.living_room_tv fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 167, in update
    power = self.get_remote().power
  File "/usr/local/lib/python3.6/site-packages/samsungctl/upnp/UPNP_Device/upnp_class.py", line 131, in __getattr__
    return self.__class__.__dict__[item].fget(self)
  File "/usr/local/lib/python3.6/site-packages/samsungctl/utils.py", line 44, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/samsungctl/remote_legacy.py", line 45, in power
    self.sock.self.sock.setblocking(0)
AttributeError: 'socket' object has no attribute 'self'

is a fat finger. a goof.

self.sock.self.sock.setblocking(0). see that line..
it is supposed to be self.sock.setblocking(0)

It took me all last night to code up a UDP SSDP discovery "server" and set up a flask server to handle the upnp requests and also handle returning the UPNP xervice xml data.

Thatss great that you are trying to do exception catching.. dong that is not the solution. there should be no error in the first place. it is supposed to work like this. if the TV is on. it will return the value. if it is off it is going to return None. there is no error that is supposed to be generated.

checking for power simply checks to see if the socket is None. because of how the websocket works and because different responses can come in for different things taking place. there is a thread that runs continually receiving data from the socket. if there is a specific piece of data requested then a call back is placed and when that receive thread gets a response it calls the callback. if receiving data fails and an error gets generated. it is caught. the socket gets closed and the thread then shifts to trying to reconnect it. this is where the power detection comes from. if the websocket is connected then the TV is on. if it is disconnected. the power is off. really simple.

Now this library works outside of Home Assistant. there are people using it. I do not know as to why it has issues in Home Assistant.

@arsaboo stated something which I am still not able to put a finger on.

the library works when you first install it. then after you restart Home Assistant it no longer functions. so now my question on that is. what is Home Assistant doing that can cause this kind of a problem? There is nothing in the code for samsungctl that is going to make it's behavior change when you restart it.

we need to stop trying to baind-aid the problem and we need to not band-aide the problem with try except clauses. w need to fnid the root cause of thee problem and repair it properly

Now python does have fantastic traceback information. and it will usually tell you spot on where the problem is. So long as everything is hard coded and nothing is dynamic made.
Well the upnp end of things is all dynamic. so the error you are seeing is not where the problem is. it is up stream from there.

remove anything that is not needed and see if the error occurs. This is going to include Home Assistant. we have some strange behavior when first installed vs after restart. So what needs to be done form here is run samsungctl all on it's own. without home assistant.

this is stated by a user that is using samsungctl without HomeAssistant

At least now I've got mute status and the ability to get and set the volume level instead of stepping up and down. These alone are significant, so thank you very much for the time and effort you have put into improving the samsungctl library. I'll be keeping an eye on your repo in hopes that a way to select source is found without requiring the MainTVAgent2 service.

as you can see the user clearly states they are able to get the mute state and what the current volume is as well as set the volume. So those specific things do in fact work. when the program is not being run inside Home Assistant. so now we shift back to the question that is being raised with the library working when first installed and then not after a restart of Home Assistant. so now the real question at hand is what is Home Assistant doing that is changing how samsungctl runs?? This is do not have the answer to. maybe someone that works on Home Assistant might be able to help and to shed a little light on it for us. I know nothing about the internals of Home Assistant. I am trying to help to get this running for the users of Home Assistant. I need help doing this. I know how samsungctl works. I need help from someone that has a really in depth knowledge of the code in Home Assistant. Home Assistant seems to have quite a bit of "voodo magic" code in it. there are functions that I cannot get a location for what calls them. I cant get a location on what even starts the samsungtv portion of the code. So someone that knowns Home Assistant is needed to help explain some of the details to me. If there was a way to be able to plug the unit tests for the library into home assistant and produce a replica of how things should be running would be a great help. I do not know if that is possible.

So my suggestion to you guys is this. test samsungctl outside of Home Assistant if you are getting the same errors then let me know. I have statements telling me that samsungctl runs fine. so we need to find out why the 2 are bumping heads.

Wee also need to remove one more thing form the equation. which is that pre built version of HomeAssistant.

Install Python 3.6
then run pip install homeassistant

run it that way. there could be some kind of a difference between the 2 that is causing a problem.

I am sure it is working outside Homeassistant. What we now need to figure out is how to get it working inside HA. My guess is the problem lies with the component and not samsungctl library.

I am not sure why a simple statement like power = self.get_remote().power does not return the right value (it mostly correctly reports False when the TV is off, but does not report True reliably when the TV is on).

Ok....so here is a slightly modified version of @jnimmo code that is working for me (state reporting is still iffy) https://paste.ubuntu.com/p/C6MfxT7JNz/

I'll also test your code out as I have a UN50J5200 TV that I'd like to get working with HA. I'll report back soon as I can.

I am using a non-Hass.IO install.

Config:

  - platform: samsungtv
    host: 192.168.1.46
    method: encrypted

This is what I get:

2019-02-07 16:44:01 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.samsungtv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-07 16:44:05 ERROR (Thread-2) [samsungctl] Unable to acquire TV's mac address
...
2019-02-07 17:28:38 INFO (Thread-10) [custom_components.media_player.samsungtv] Samsung TV 192.168.1.46 added as 'Samsung TV Remote'
2019-02-07 16:44:28 ERROR (MainThread) [samsungctl] Unable to power on the TV, check network connectivity
...
2019-02-07 16:44:29 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 232, in async_update_ha_state
    state = self.state
  File "/home/homeassistant/.homeassistant/custom_components/media_player/samsungtv.py", line 224, in state
    power = self.get_remote().power
  File "/home/homeassistant/.homeassistant/custom_components/media_player/samsungtv.py", line 178, in get_remote
    self._remote.open()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/samsungctl/utils.py", line 44, in wrapper
    result = func(*args, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/samsungctl/remote_encrypted/__init__.py", line 159, in open
    raise RuntimeError('Unable to pair with TV.')
RuntimeError: Unable to pair with TV.

I had the TV already turned on when I started Home Assistant.

what is causing thee issue I think is the pairing process and Home Assistant. this is because the TV displays a pin and it has to be entered into the computer running the program.

Home assistant is not geared to deal with having to have user input like that. II am not sure how to fix that issue.

i believe that the 5200 series TV's are not capable of being controlled remotely. you can confirm this by using the smartview application. the application will give you DLNA ability and media control. but you will not be able to do things like change the channel. or bring up the setup menu on the TV

I don't see any PIN on my TV (UN75NU8000). I just see a prompt to allow access and I have done that. So, should not be a pairing issue here. Although not perfect, I am able to communicate with the TV (turn on/off).

I am also not able to use my SmartView app with my TV. I have heard a few other folks confirm this.

I am talking about the encrypted method TV's the H and J series TV's.

I believe there is still going to be an issue with the SSL websocket baseed TV's. because of that get_remote method.

I say this because the pairing process for the SSL TV's can take up to 30 seconds. this is going to cause a problem because the "remote" can be created from any of the methods or properties that make a call to get_remote. I believe the startup of the class has a timeout of 60 seconds we may want to move the initialization of the remote to the __init__ method.

I also updated the develop branch for samsungctl. I reorganized the whole UPNP process. and got the unittests working for some of the upnp functions. everything is testing out with no errors.

remove samsungctl from your Home Assistant installation revert back to the code in the first post and lets see if it works. I am feeling pretty good about how it is set up. So i am hoping that all goes well.

I also added some "smoothing" code for the websocket connection. so if there is some kind of an error that happens but the connection is not terminated. it will absorb this and continue doing what it needs to do. if the error happens 3 times in a row then it will close the connection and try and reopen it.

@arsaboo

you are unable to run SmartView because you have an SSL websocket connection. the application does not support it. but for the person with the 2015 TV. it does support it.

@firstof9

There is something off with your log.

019-02-07 16:44:01 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.samsungtv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
  ----->   2019-02-07 16:44:05 ERROR (Thread-2) [samsungctl] Unable to acquire TV's mac address
...
 ------>  2019-02-07 17:28:38 INFO (Thread-10) [custom_components.media_player.samsungtv] Samsung TV 192.168.1.46 added as 'Samsung TV Remote'
-------> 2019-02-07 16:44:28 ERROR (MainThread) [samsungctl] Unable to power on the TV, check network connectivity
...
2019-02-07 16:44:29 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 232, in async_update_ha_state
    state = self.state
  File "/home/homeassistant/.homeassistant/custom_components/media_player/samsungtv.py", line 224, in state
    power = self.get_remote().power
  File "/home/homeassistant/.homeassistant/custom_components/media_player/samsungtv.py", line 178, in get_remote
    self._remote.open()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/samsungctl/utils.py", line 44, in wrapper
    result = func(*args, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/samsungctl/remote_encrypted/__init__.py", line 159, in open
    raise RuntimeError('Unable to pair with TV.')
RuntimeError: Unable to pair with TV.

I marked the lines that are screwy. Look at the date/time stamps.. specifically the time.

Now I would say that the cause could be DST. but it is not an hour off. it is 44 minutes off
and even if for some reason it's 44 minutes off, the seconds should line up properly. the powering on process of the TV takes 20 seconds in order for it to timeout and for you to get the "Unable to power on the TV, check network connectivity" message. the time stamp for the message above which would be the samsungtv component getting started shows the seconds being 38 and then what would be 10 seconds before the the message about the samsungtv component getting started, so that does not match the 20 seconds it takes from the start of the power on process to the time the error gets printed. Plus the fact that you have a message telling you that it is unable to locate the mac address. which the power process would not even run if that is the case.

here is the code for the power on process

            # here is the checking for the mac address
            if self.mac_address:
                # this is the stop counter  
                count = 0
                wake_on_lan.send_wol(self.mac_address)
                event.wait(1.0)
                # this is the loop to keep sending the wol packet it will only exit if the counter has reached 20 or if the TV is powered on
                while not self.power and count < 20:
                    if not self._running:
                        try:
                            self.open()
                        except:
                            pass
                    wake_on_lan.send_wol(self.mac_address)
                   # this is a wait of 1 second between loops. it will take at most 20 seconds before the loop exits
                    event.wait(1.0)

                    # increment the counter by 1 each loop
                    count += 1
                # after the loop exits check the counter. if it is 20 then print the message
                if count == 20:
                    logger.error(
                        'Unable to power on the TV, '
                        'check network connectivity'
                    )
            else:
                # this gets printed out if there is no mac address
                logging.error('Unable to get TV\'s mac address')

so as you can see the message in that log do not match what the code does not even close.

so I am not sure what is going on with your setup. my suggestion would be to uninstall everything and start from scratch. I do not even know where to begin to even try to help. That is if you are able to control the TV from SmartView.

ok so here we go again.

I updated the code above. moves all statuses into the update method. I am thinking this method has a greater timeout then other properties/methods.

I also did away with the whole get_remote method. because of the longer connection times associated with the SSL potentially requiring a confirmation on the TV i did not want this happening in a call that has a small timeout.

I also added a pin input mechanism for those of you with the encrypted websocket connections H and J (2014, 2015) TV's. I had to change the samsungctl library in order to accept the new mechanism for the pin entry. so i did a version bump on the develop branch to handle this. this will ensure that if using the code in the first post the right samsungctl will be installed that can support it.

I also changed the source list based on some code that @arsaboo had posted. slightly modified to provide all of the source keys as well as the key to iterate over the sources I did this because some TV's do not support the discrete source key codes.

I also changed the source list for those TV's that do support querying the TV for the current source the list will be empty if the TV is off and populated when the TV is on. if the TV does not support being queried the displayed source will be "Unknown"

I also hold storage of the current source (if supported) as well as thee current volume even when the TV is off. these things will not change when you turn the TV on. so you can see if the TV will have a blasting volume before turning the thing on LOL.

if someone wants to give it a test run and see if it works that would be great.

I have hammered out quite a few issues this past day. I am going to connect my 2 Samsung TV's in the next day or 2. one is 2011 (the last year they made the TV's with a full API. The last year they also made that is considered reliable) and the other is a 2014 (it's a pretty dumb TV so dunno if it will support remote control)

I got this exception:

Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 123, in setup_platform
    add_entities([SamsungTVDevice(config, uuid)])
  File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 204, in __init__
    self._name = self._config.name
AttributeError: 'collections.OrderedDict' object has no attribute 'name'

Configuration.yaml:

media_player:
  - platform: samsungtv
    host: <IP>
    name: Living Room TV
    description: description of TV

I updated the code in the first post to fix that error. sorry about that forgot to change the config that was being passed to the constructor of the component class

@kdschlosser This is SIGNIFICANTLY better. No errors in the logs. Turning on works fine, but it reports off even when the TV is on or a few times the other way around.

I got this:

2019-02-08 15:16:56 ERROR (SyncWorker_3) [samsungctl] Unable to acquire TV's mac address
2019-02-08 15:16:56 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/samsungtv.py", line 121, in setup_platform
    request_configuration(samsung_config, hass, uuid, add_entities)
  File "/config/custom_components/media_player/samsungtv.py", line 136, in request_configuration
    configurator = hass.components.configurator
AttributeError: 'NoneType' object has no attribute 'components'

configuration.yaml

   platform: samsungtv
   host: !secret master_bedroom_tv_ip
   method: encrypted

Model: UE32J5200

Thanks @kdschlosser for your work. I have a UE50H6400 Samsung TV of 2014 year and i want to try your code ASAP :-).

Once again, thanks for your effort.

So, just to debug, I turned on the TV manually using the remote and waited for the state to update in HA. Even after 5 minutes, the state in HA stayed off.

hi,
im running hassio and have a Samsung UE55MU6120

my config is:

  - platform: samsungtv
    host: mytvip
    name: Samsung TV

edit2:
it doesn't like it if the tv is off when HA is restarted. i kept getting this error.
2019-02-08 16:25:45 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10

manually turning it on it will appear on in HA roughly 5secs later, yet it never changes when manually turned off, still shows as on.

remotely if you turn it on after 10secs it appear off in HA, same with turning it off it'll appear on in HA.

its as if it think its on/off but doesn't really check

the volume works every time without fail.

i can't
change source

hope this help, as i really want to have my tv hook up to home assistant.

OK so it is check for power. just have to figure out why the state is not changing properly.
if it thinks the TV is on there should be a list of sources you can select from.. can you tell me what is in that list?

if the list looks like this

                    'Source',
                    'Component 1',
                    'Component 2',
                    'AV 1',
                    'AV 2',
                    'AV 3',
                    'S Video 1',
                    'S Video 2',
                    'S Video 3',
                    'HDMI',
                    'HDMI 1',
                    'HDMI 2',
                    'HDMI 3',
                    'HDMI 4',
                    'FM-Radio',
                    'DVI',
                    'DVR',
                    'TV',
                    'Analog TV',
                    'Digital TV'

have you tried each and every item in the list?

what works with the volume? using the volume up and down?? or the direct input of the volume?
have you tried the mute?

So, I turned on the TV from the media_player entity and it turned on, but the status inside HA quickly went back to off. Here are the attributes of the media_player entity before it went to off:

{
  "volume_level": 0,
  "is_volume_muted": false,
  "source": "Unknown",
  "source_list": [
    "Source",
    "Component 1",
    "Component 2",
    "AV 1",
    "AV 2",
    "AV 3",
    "S Video 1",
    "S Video 2",
    "S Video 3",
    "HDMI",
    "HDMI 1",
    "HDMI 2",
    "HDMI 3",
    "HDMI 4",
    "FM-Radio",
    "DVI",
    "DVR",
    "TV",
    "Analog TV",
    "Digital TV"
  ],
  "friendly_name": "Living Room TV",
  "supported_features": 20413
}

Also, when this happens, I see this in the logs (this is despite it turning on the TV):

2019-02-08 12:18:29 INFO (SyncWorker_2) [samsungctl] Is the TV on?!? 
2019-02-08 12:18:29 ERROR ERROR (Thread-7) [samsungctl] Unable to power on the TV, check network connectivity

@gabrielcolceriu

your model TV may not support being turned on remotely. that is not what the error is about I am just letting you know ahead of time. I have fixed the code in the first post. to solve that error. let m know what the results are.

@arsaboo

this is what I am going to need you to do.

one thing at a time we need to test.. now we do know that how it is reporting power is not working properly. so I will add debug logging so we can see exactly what is going on.

this is what I want you to test for and tell me if it is working properly. and if it is not what is not working correctly about it and any errors

mute
volume up
volume down
volume direct input
source list
changing source
play
pause
fast forward
rewind
channel entry

the next 2 i do not care about what is reported. I do care if the feature is working
turning on
turning off

The problem is none of those functions are available when the media_player entity is off:
image

I did also want to mention that the power on and power off sequence takes roughly 17 seconds for on and about 12 seconds for off.

do not pay attention to what the TV is doing. just because the screen is on or off is not what dictates when the TV is actually considered on or off. These TV's are Computers. so when you turn you computer on. just because the screen is on does it mean the computer is booted?? No it does not. so the same thing goes for the TV. it takes a while for the TV to boot up. as well as it takes a while for it to shutdown. so when the websocket service is finally started or stopped (which is one of the last things the TV does) then it is considered on or off.

so be patient when telling it to turn on or off. it may take 20 seconds for the state to change in HomeAssistant. and just like any computer. the newer the TV the faster it will be. and do remember that if you have a lot of applications on it. this can also impact the speed in which the TV boots. Also as a good rule of thumb. the more ding dongs and ho ho's (features) the TV has the longer it is going to take to boot. so the top of the line samsung TV of this year is probably going to take longer to turn on then say something middle of the road

I will force the script into an always on state so we can see what is happening. and also add the additional logging information...

@kdschlosser
Volume up and down. Work fine
The slider and mute don't do anything

I did try all sources and nothing happened

The tv was off for 30 mins, it's now been on for 20mins and HA still thinks it's off

Good post about the cycle on off time :+1:

OK I updated the code in the first post. the TV should always show up in Home Assistant as being on

I also added a bunch of debugging lines. this information is going to print out every 10 seconds I am guessing.

it will also tell us what the source is being set to when you try to change it.

You will need to put Home Assistant into debugging mode. I am not sure how to do this. if someone can explain how to do it that would be helpful

I am glad to see all of the upnp errors are gone with this version of samsungctl.

Use the following in configuration.yaml to obtain the logs

logger:
  default: error
  logs:
    custom_components.media_player.samsungtv: info
    samsungctl: info

OK i updated the code in the first post again.

I made a change to the power detection of the TV in samsungctl.
the code in the first post is still going to lock thee TV in an always on state in Home Assistant.

I had to change all the _LOGGER.info to LOGGER.debug and here are the findings. Volume up and down worked reliably. Mute did not work for me. Also, not all sources worked for me. HDMI and TV worked. But, I could not get it to switch back to HDMI4, for example.

Here are the logs: https://hastebin.com/inegowoguh.py

Just to clarify again, I am using a Sonos Playbar for sound and hence the Volume levels may be none in the logs.

if you keep on using the source of HDMI does it rotate through the HDMI ports?

does your TV only have HDMI ports?

any way i can get you to change the setting in the TV back to internal for the sound? this way we can test the volume aspect of it

It also looks as tho I have solved the issue with the power state. I am going to change thee code in the first post so Home Assistant will set the state of the TV accordingly.

I am not at home otherwise would have tested that. I am testing remotely with my Arlo pointed towards my camera :wink:

LOL... if you have the ability to run samsungctl without HomeAssistant you could use the interactive mode to navigate to the menu setting and change it :smile:

Here are the ports on my TV. Let me know when you update the code and I can test it again for the power

BTW...you should seriously be on the HA discord server. It is a lot easier that way.

also. one other thing with the sources. if the TV does not have something plugged into a port it may not allow you to change to it. depends on the year and model of the TV i think.

I know my 2011 TV is like that

this is better because the history of what we have tried is easily visible for all to see.

I think something like that may be going on. I only have two HDMIs used. Apple TV on HDMI2 and Shield on HDMI4.

plus I am 45.. memory is slipping I do need to go back and see if i have tried something or not.. :wink:

code updated in first post

With the current code, I was not able to turn on the TV (which I could do earlier). HDMI is doing something, but not quite reliably. Like it changed to HDMI2 when I pressed it the first time, but it did not change to HDMI4 when I pressed it again. Here are the logs:

https://hastebin.com/iqiqaviyik.py

2019-02-08 13:32:08 ERROR (Thread-4) [samsungctl] Unable to power on the TV, check network connectivity
this happens when it has an issue with sending the WOL packet.

try restarting Home Assistant and see if it starts working.

With the current code, I was not able to turn on the TV (which I could do earlier). HDMI is doing something, but not quite reliably. Like it changed to HDMI2 when I pressed it the first time, but it did not change to HDMI4 when I pressed it again. Here are the logs:

https://hastebin.com/iqiqaviyik.py

Likely that Home Assistant won't be sending through the second HDMI command as it already things it is on HDMI.
Could add a second KEY_HDMI line so you can alternate between them to advance inputs (i.e. HDMI (Next)).

Also keep in mind Home Assistant's multi-threading can make things fun

from the logs it does appear the TV state is now working correctly. why exactly your TV is not turning on is the question. if the restart does not solve it then I will have to add some code to see what is going on.

@jnimmo
No it is sending the command. When Home Assistant checks the source I am returning Unknown

okay with logger on i get the following

if the tv is off when HA is restarted, it stated the tv is unkown then about 30secs later it shows off
here is what the logs captures

2019-02-08 18:39:30 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:39:31 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method WebSocketResponse._send_heartbeat of <WebSocketResponse Switching Protocols GET /api/websocket >>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 245, in uvloop.loop.TimerHandle._run
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_ws.py", line 101, in _send_heartbeat
    self._loop.create_task(self._writer.ping())  # type: ignore
AttributeError: 'NoneType' object has no attribute 'ping'
2019-02-08 18:39:41 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:39:52 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:40:03 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:40:14 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:40:25 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:40:28 INFO (SyncWorker_18) [samsungctl] Is the TV on?!?

turned on manually HA doesn't change state (still off)
turn on remotely HA state updates yet tv doesn't turn on (waited over 30 secs)

regarding sources
nothing works

2019-02-08 18:46:33 INFO (SyncWorker_5) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI1', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:46:49 INFO (SyncWorker_8) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI3', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:46:59 INFO (SyncWorker_4) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI4', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:14 INFO (SyncWorker_14) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_COMPONENT1', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:17 INFO (SyncWorker_12) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_COMPONENT2', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:21 INFO (SyncWorker_18) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_AV1', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:23 INFO (SyncWorker_11) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_AV2', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:26 INFO (SyncWorker_6) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_AV3', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:30 INFO (SyncWorker_4) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_SVIDEO1', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:32 INFO (SyncWorker_10) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_SVIDEO2', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:35 INFO (SyncWorker_10) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_AV3', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:39 INFO (SyncWorker_15) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_DVI', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:44 INFO (SyncWorker_2) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_DVR', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:47 INFO (SyncWorker_4) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_TV', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:50 INFO (SyncWorker_5) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_ANTENA', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 18:47:53 INFO (SyncWorker_4) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_DTV', 'Option': 'false', 'TypeOfRemote': 

Also keep in mind Home Assistant's multi-threading can make things fun

yeah I am finding that out. that coupled with some glitches n samsungctl it is hard to isolate the exact cause of a problem.

@phairplay

model number of your TV?

@phairplay

did you also use the latest code from the first post. you have been away for a bit. and the code has been updated several times since then.

the reason I ask this is because your logs show none of the new debugging information I added.

UE55MU6120

yes i've update the code every time you mention it 👍

ill try now to be 100 sure

it also appears that you have other issues with Home Assistant as well

2019-02-08 18:39:31 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method WebSocketResponse._send_heartbeat of <WebSocketResponse Switching Protocols GET /api/websocket >>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 245, in uvloop.loop.TimerHandle._run
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_ws.py", line 101, in _send_heartbeat
    self._loop.create_task(self._writer.ping())  # type: ignore
AttributeError: 'NoneType' object has no attribute 'ping'
2019-02-08 18:39:41 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10

i would really love to know what the timeeout period is on this thing. and if that Warning appears does that mean that it stopped trying to run the update for that interval. or is it simply hung?

also. you have to turn on debugging in Home Assistant @arsaboo posted instructions on how to do this a few posts back

019-02-08 19:00:07 INFO (SyncWorker_11) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_HDMI1
2019-02-08 19:00:20 INFO (SyncWorker_17) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI3', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:41 INFO (SyncWorker_11) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI4', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:45 INFO (SyncWorker_7) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_VOLUP', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:47 INFO (Thread-61) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:48 INFO (Thread-61) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}

now it appears off then appears on
when i turn the tv on manually i can turn it off via HA

the duplicate ip is odd

2019-02-08 19:03:08 INFO (SyncWorker_13) [custom_components.media_player.samsungtv] Ignoring duplicate Samsung TV myip
2019-02-08 19:04:15 INFO (Thread-121) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:04:15 INFO (Thread-121) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:04:26 INFO (Thread-121) [samsungctl] Unable to power off the TV
2019-02-08 19:05:13 INFO (Thread-136) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:05:13 INFO (Thread-136) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:05:24 INFO (Thread-136) [samsungctl] Unable to power off the TV

updateed code in first post. i also found the problem when starting Home Assistant with the TV off.

@phairplay

I need to see the entire logs. not small chunks please attach them to a post as a text file

I am going to bail on you guys until early this evening. I have to replace the rear brake calipers on my Lincoln damned slider is frozen and causing issues. and now I have to go out in -4F : -20C temperatures and replace them.. YAY FUN IS!!! at least it's not snowing.

here is the logs starting from a restart

2019-02-08 18:56:17 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.samsungtv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-08 18:57:10 INFO (SyncWorker_6) [custom_components.media_player.samsungtv] Samsung TV 192.168.1.174 added as 'Samsung TV'
2019-02-08 18:57:40 WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.spare_room_samsung_ue55mu6120_2 is taking over 10 seconds
2019-02-08 18:57:41 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:57:51 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:58:06 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:58:17 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:58:28 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:58:39 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:58:50 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:59:01 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:59:12 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:59:23 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:59:34 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:59:45 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-08 18:59:45 INFO (SyncWorker_6) [samsungctl] Is the TV on?!?
2019-02-08 19:00:07 INFO (SyncWorker_11) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_HDMI1
2019-02-08 19:00:20 INFO (SyncWorker_17) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI3', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:41 INFO (SyncWorker_11) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI4', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:45 INFO (SyncWorker_7) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_VOLUP', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:47 INFO (Thread-61) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:48 INFO (Thread-61) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:00:58 INFO (Thread-61) [samsungctl] Unable to power off the TV
2019-02-08 19:01:42 INFO (Thread-75) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:01:42 INFO (Thread-75) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:01:53 INFO (Thread-75) [samsungctl] Unable to power off the TV
2019-02-08 19:02:31 INFO (Thread-95) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:02:32 INFO (Thread-95) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:02:42 INFO (Thread-95) [samsungctl] Unable to power off the TV
2019-02-08 19:02:54 INFO (Thread-102) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:02:54 INFO (Thread-102) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:03:04 INFO (Thread-102) [samsungctl] Unable to power off the TV
2019-02-08 19:03:08 INFO (SyncWorker_13) [custom_components.media_player.samsungtv] Ignoring duplicate Samsung TV 192.myip
2019-02-08 19:04:15 INFO (Thread-121) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:04:15 INFO (Thread-121) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:04:26 INFO (Thread-121) [samsungctl] Unable to power off the TV
2019-02-08 19:05:13 INFO (Thread-136) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWER', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:05:13 INFO (Thread-136) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_POWEROFF', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-08 19:05:24 INFO (Thread-136) [samsungctl] Unable to power off the TV
2019-02-08 19:06:54 INFO (Thread-49) [samsungctl] Websocket closed
2019-02-08 19:12:22 INFO (SyncWorker_15) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:22 INFO (SyncWorker_16) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:24 INFO (SyncWorker_19) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:26 INFO (SyncWorker_0) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:26 INFO (SyncWorker_12) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:34 ERROR (Thread-235) [samsungctl] Unable to power on the TV, check network connectivity
2019-02-08 19:12:47 INFO (SyncWorker_10) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:48 INFO (SyncWorker_9) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:49 INFO (SyncWorker_13) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:49 INFO (SyncWorker_0) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:49 INFO (SyncWorker_3) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:49 INFO (SyncWorker_2) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:12:51 INFO (SyncWorker_12) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLDOWN
2019-02-08 19:12:51 INFO (SyncWorker_11) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLDOWN
2019-02-08 19:12:52 INFO (SyncWorker_12) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLDOWN
2019-02-08 19:12:52 INFO (SyncWorker_5) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLDOWN
2019-02-08 19:13:02 INFO (SyncWorker_10) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:13:03 INFO (SyncWorker_11) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:13:06 ERROR (Thread-243) [samsungctl] Unable to power on the TV, check network connectivity
2019-02-08 19:13:44 ERROR (Thread-253) [samsungctl] Unable to power on the TV, check network connectivity
2019-02-08 19:16:44 INFO (SyncWorker_11) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:16:45 INFO (SyncWorker_18) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP
2019-02-08 19:16:46 INFO (SyncWorker_9) [custom_components.media_player.samsungtv] TV is powering on, not sending command: KEY_VOLUP


Wow -20c I'm in the UK our country falls apart at -5c

So, some websocket errors with the most recent code: https://hastebin.com/qawosijiki.py

After those errors appeared, I was not able to turn off the TV.

OK so i see where some of the issue is.

from thee time the TV is actually powered off

2019-02-08 14:17:51 DEBUG (SyncWorker_2) [custom_components.media_player.samsungtv] Living Room TV TV: Power is Off

and when the websocket errors out and closes

2019-02-08 14:18:45 INFO (Thread-2) [samsungctl] Websocket closed

is 54 seconds. this is no good.

updated code in first post.

@phairplay

I am at 8500 feet (2590.8 meters) above sea level. in Colorado (Rocky Mountains) about an hour and a half away from the highest mountain in North America. Put it to ya this way. nearest gas station is a tad over 25 minutes away. (If i drove like the law says I should but since I don't it takes me about 15). In the last 3 weeks we have gotten 4 feet of snow.

and -20c is nothing. we call that "brisk" here.. now when it hits -30c (and it does and stays like that for a month sometimes) that is a might bit chilly. We get this really cool phenomenon that happens. we call it "Thunder Snow". That is when you have a lightning storm while it is snowing..

@phairplay

also I am starting to think you have a special-ed TV on your hands over there. the thing should be riding the little yellow short bus while wearing a helmet and licking the window. because it's slowwwww..... that is causing the time out problem in the async handler. I am going to move the construction of the remote to the __init__ method and see if that solves the problem . I know there is a 60 second timeout on that.

For me the current code works almost for my TV ue55mu6179
Mute does not work
Power On not working (I think it is not possible with this model)
Source change to HDMI works, but not back to TV.
2019-02-08 21:58:28 ERROR (MainThread) [custom_components.media_player.samsungtv] Samsung TV TV: Unsupported media type

@kdschlosser
Wow that's insane!
Haha!
Doesnt surprise me my main tv is Sony android and the software it stupidly slow too, I had to buy a shield to watch plex and netflix

wait is not allowed in HA code (it is fine for now). Once we get this working, we need to optimize the code so that it can be submitted.

@arsaboo

what do you mean??

@phairplay
have a look at this...

I wrote a Sony TV Gen3+ API, I think it is still the most complete API made to date. I could be wrong in that tho. I have a develop branch that has a bunch more added to it. the develop branch is not in a working state and it actually has been a long time since I have put any work into it.

https://github.com/kdschlosser/SonyAPI

we have couple of wait(30) in the code, which may not be allowed in the component.

@kdschlosser Verified with the SmartView app it detects the TV but no controls :( oh well.

Thee manufacturers go bargain basement in terms of processor and memory on these things. and thy they load them up till they are maxed out. My Samsung TV gets hot as hell in the back of it. I do not understand why that is.. the LED's release almost no heat. I have a 5000 watt APC UPS that is something like 98% efficient at converting 240v AC to 48v DC and vice versa and at 100% capacity it doesn't throw off as much heat as the TV does. cheap ass components. not efficient. probably a 60% efficient power supply in the thing. so if it draws 300 watts 120 of it is going into the air.

Here in the US people must enjoy getting robbed by the utility companies. In the UK the electric is 240v yes? well here it is 120. there are 2 legs of 120 coming into a house to make 240 for things like stoves and dryers. thee biggest hoot is because most everything is 120 you can end up with a higher current draw on one of the legs. a lot of times it is actually a pretty substantial amount higher.. But I only have one electric meter. and it reads from whatever leg has the highest current draw. what I did with that batter backup is I get a 120v step down transformer for it and I wired it into the house. so now almost everything in my house is tied off that battery backup. and that battery backup splits the load evenly across the 2 legs. I dropped my electric bill by 25% ish. I am still using the exact same amount of power. and I have all the same things running. the only difference is the identical loads on both legs of the house

@arsaboo

that is not what you think it is. and those are not stalling the program at all. and they are not inside of a Home Assistant thread. typically threading.Event.wait() is OK to use it is time.sleep() that is the evil one.

The only thing I do not see with home assistant is anything that will allow any connections to be closed gracefully. I have been poking about the components. and I have not come across a single reference to any kind of a routine that will allow the closing of a socket or a file. I do not understand that. Normally I would have some kind of a way to exit the wait and the loop if there is one. I am not exactly sure how things get closed up properly. doesn't make any sense to me.

@firstof9

time to buy a new TV.. LOL.. please not Samsung tho. Samsung has been on a downward spiral for the last few years.

my main TV is a 120" projection. I bought an Epson projector on e-bay with something like 50 hours on it for 500 bucks. i built the screen myself (I bought the screen material from a company that makes one of the best screens). the screen cost me around 250 start to finish. I'll tell you what... it is the cheapest TV I have ever bought. and I am extremely happy with it.
I went with the Epson projector because of the top bottom offset and also it's really short throw distance of 11 feet for 120". And it is the only projector that has a front air intake and a front exhaust. so it can be boxed in.

@kdschlosser I think moving it over to using asyncio will allow handling closing connections gracefully
When Home Assistant is logging those warnings about update taking longer than 10 seconds it doesn't cancel the update, just a warning the call is taking too long.
We can specify in the media_player config
scan_interval: 60
to increase this time

I'm away at the moment but can do some more testing on TVs on Monday

@kdschlosser Just briefly tested the updated code and it works quite well. Mute works for me and the states are also updating. Mute and sources are not working and those may be idiosyncratic to my situation. Will test some more tomorrow.

I agree with @jnimmo that moving everything to async will make it efficient, but even in the current code there is no I/O in the properties.

it is using async communications if you look at the media_player parent class. every property has a matching method that begins with async_ and I am pretty sure this is what Home Assistant calls and that method then returns the property.

unless i rewrite samsungctl to use async which would then make it not compatible with python 2 (which I am not going to do) it is still not going to close the websocket connection. it appears as tho the possibility of ending up with an orphaned socket or file or whatever is OK by Home Assistant.

an example would be the Harman Kardon component. It crates a socket connection and there is no way to shut it down.

Now.. I can code in a mechanism into samsungctl that would connect the UPNP and the websocket at the same time. instead of on after the other. this would speed things up. I am going to do that.

OK I have made some headway.. I set up my TV and Home Assistant.

There are a few things that were wrong. one being what i would say is a bug. but it really isn't. it's from samsung not conforming to UPNP specification.

so If i get a location of

"http://192.168.1.201:52235/MainTVServer2/MainTVServer2Desc.xml"

and when I open up that xml and parse it and i am looking specifically the service information. shown below

<serviceList>
            <service>
                <serviceType>urn:samsung.com:service:MainTVAgent2:1</serviceType>
                <serviceId>urn:samsung.com:serviceId:MainTVAgent2</serviceId>
                <controlURL>/MainTVServer2/control/MainTVAgent2</controlURL>
                <eventSubURL>/MainTVServer2/event/MainTVAgent2</eventSubURL>
                <SCPDURL>MainTVAgent2.xml</SCPDURL>
            </service>
</serviceList>

look at the controlURL the eventSubURL and then the SCPDURL nodes

Now in the controlURL and the eventSubURL it contains the full path. so all I would need do is thee following.

http://192.168.1.201:52235/MainTVServer2/control/MainTVAgent2

and I am where i need to be.

the SCPDURL is supposed to be the the same. Now the hoot is with the H and J series TV's it is lik what you see above. on my legacy TV it is not. because if I connect to

 http://192.168.1.201:52235/MainTVAgent2.xml

it does not exist.

but if i connect to

http://192.168.1.201:52235/MainTVServer2/MainTVAgent2.xml

i get the information I am looking for.
this is causing issues with volume, mute, sources. things like that.

the other thing I have discovered is that for some really strange reason if the TV gets hit with packets when it first turns on it has a fit about it and shuts down the networking on the TV. I am not sure how to go about handling that one because that is how we handle power detection on the TV.

one other very strange issue is the damned thing works perfect until i restart Home Assistant. once i do that it stops working until i delete the samsungctl config file. and restart Home Assistant. then it is back up and running again. Strange.. I do not have these issues running the same samsungctl library and python that Home Assistant uses and it works just fine. just like it is supposed to... so now the mystery is why does it work with a new config file and not an old one. and why does it work fine with Home Assistant taken out of the equation and eveything else remains the same. there has got to be some kind of a glitch somewhere in home assistant where it is causing issuse with reading data from a file.

So, I have a UE55HU7500 and I'm getting the following errors whenever I execute a command:
The volumne indicator is also incorrect (says volume is set to 0)

2019-02-09 10:14:26 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=select_source, service_data=source=HDMI 1, entity_id=media_player.living_room_tv>
2019-02-09 10:14:26 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140623537946576] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'media_player', 'service': 'select_source', 'service_data': {'source': 'HDMI 1', 'entity_id': 'media_player.living_room_tv'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 9, 9, 14, 26, 640881, tzinfo=<UTC>), 'context': {'id': 'a5703af0b961481392c9b632cfde4a1a', 'user_id': None}}}
2019-02-09 10:14:26 DEBUG (SyncWorker_9) [homeassistant.components.media_player.samsungtv] Living Room TV TV: changing source to KEY_HDMI1
2019-02-09 10:14:26 DEBUG (SyncWorker_9) [root] RemoteWebsocket.control(key='KEY_HDMI1')
2019-02-09 10:14:26 INFO (SyncWorker_9) [samsungctl] Sending control command: {'Cmd': 'Click', 'DataOfCmd': 'KEY_HDMI1', 'Option': 'false', 'TypeOfRemote': 'SendRemoteKey'}
2019-02-09 10:14:26 DEBUG (SyncWorker_9) [root] RemoteWebsocket.send(method='ms.remote.control', Cmd='Click', DataOfCmd='KEY_HDMI1', Option='false', TypeOfRemote='SendRemoteKey')
2019-02-09 10:14:26 DEBUG (Thread-2) [root] RemoteWebsocket.on_message(message='{"event":"ms.error","data":{"message":"unrecognized method value : ms.remote.control"}}')
2019-02-09 10:14:26 DEBUG (Thread-2) [samsungctl] incoming message: {"event":"ms.error","data":{"message":"unrecognized method value : ms.remote.control"}}
2019-02-09 10:14:26 DEBUG (SyncWorker_6) [root] RemoteWebsocket.power()
2019-02-09 10:14:27 DEBUG (SyncWorker_6) [root] RemoteWebsocket.power => True
2019-02-09 10:14:27 DEBUG (SyncWorker_6) [homeassistant.components.media_player.samsungtv] Living Room TV TV: Power is On
2019-02-09 10:14:27 DEBUG (SyncWorker_6) [homeassistant.components.media_player.samsungtv] Living Room TV TV: Volume = None
2019-02-09 10:14:27 DEBUG (SyncWorker_6) [homeassistant.components.media_player.samsungtv] Living Room TV TV: Mute = None
2019-02-09 10:14:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140623540434424] Sending {'id': 14, 'type': 'result', 'success': True, 'result': None}
2019-02-09 10:14:29 DEBUG (SyncWorker_4) [root] RemoteWebsocket.power()
2019-02-09 10:14:29 DEBUG (SyncWorker_4) [root] RemoteWebsocket.power => True

I should add that I didn;t get the PIN code popup screen (from TV or HA) don't know if I should have expected this?

@kdschlosser

configuration.yaml

   platform: samsungtv
   host: !secret master_bedroom_tv_ip
   method: encrypted

Model: UE32J5200

Running with the latest code & with the logger on info for this custom_component.

default: error
  logs:
    custom_components.media_player.samsungtv: info
    samsungctl: info

got only this on logs:

2019-02-09 13:58:27 ERROR (SyncWorker_9) [samsungctl] Unable to acquire TV's mac address
2019-02-09 13:58:27 INFO (SyncWorker_9) [custom_components.media_player.samsungtv] Samsung TV 10.10.10.151 added as 'Samsung TV Remote'

Also there is no media_player.samsung_tv_remote or something like that on HA.

@kdschlosser

configuration.yaml

   platform: samsungtv
   host: !secret master_bedroom_tv_ip
   method: encrypted

Model: UE32J5200

Running with the latest code & with the logger on info for this custom_component.

default: error
  logs:
    custom_components.media_player.samsungtv: info
    samsungctl: info

got only this on logs:

2019-02-09 13:58:27 ERROR (SyncWorker_9) [samsungctl] Unable to acquire TV's mac address
2019-02-09 13:58:27 INFO (SyncWorker_9) [custom_components.media_player.samsungtv] Samsung TV 10.10.10.151 added as 'Samsung TV Remote'

Also there is no media_player.samsung_tv_remote or something like that on HA.

What happens if you drop the method: line in your configuration.yaml? @kdschlosser says in his opening post that you should only specify the method if you run into problems

@kdschlosser
configuration.yaml

   platform: samsungtv
   host: !secret master_bedroom_tv_ip
   method: encrypted

Model: UE32J5200
Running with the latest code & with the logger on info for this custom_component.

default: error
  logs:
    custom_components.media_player.samsungtv: info
    samsungctl: info

got only this on logs:

2019-02-09 13:58:27 ERROR (SyncWorker_9) [samsungctl] Unable to acquire TV's mac address
2019-02-09 13:58:27 INFO (SyncWorker_9) [custom_components.media_player.samsungtv] Samsung TV 10.10.10.151 added as 'Samsung TV Remote'

Also there is no media_player.samsung_tv_remote or something like that on HA.

What happens if you drop the method: line in your configuration.yaml? @kdschlosser says in his opening post that you should only specify the method if you run into problems

This is what i get without the method

2019-02-09 15:24:25 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='10.10.10.151', port=8001): Max retries exceeded with url: /api/v2/ (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/samsungtv.py", line 117, in setup_platform
    method=method,
  File "/config/deps/lib/python3.6/site-packages/samsungctl/config.py", line 321, in wrapper
    mac=mac
  File "/config/deps/lib/python3.6/site-packages/samsungctl/config.py", line 63, in __init__
    timeout=3
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.10.10.151', port=8001): Max retries exceeded with url: /api/v2/ (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))

@kdschlosser So, I am not facing the second bug that you indicated (requiring you to delete the conf file after restarting HA). How did you install HA? Can you check the permission of the conf file (HA is very picky about file permissions)?

On the other issue (hitting the TV with packets on startup), we can use the optimistic mode (there are lot of components that do that) where we assume the state. As long as we do the necessary checks beforehand, this should work. We can postpone the initial burst of packets for some time so that the rest of the component works. Incidentally, I don't seem to be affected by this (at least yet).

there is going to be a variation in how the TV's respond throughout the years and models. I only have a legacy to test with at the moment. I have not tried my H series yet. I will have to makee a patch cable for it and have it span 2 floor to plug it into my server rack (no wifi card in that one) an it is in a temporary location at the moment, (House under construction)

permissions are not the problem. honestly I do not know what the problem is because it states the TV is off. as soon as i delete the config file it states the TV is on and it works.

this is to everyone.. I know there are issues with some of the features I have repaired these problems on my local setup I have not made thee updated code public yet.

@gabrielcolceriu

I am almost 100% sure that your TV is not compatible Your TV dos not support being controlled remotely.

quoting @firstof9

I'll also test your code out as I have a UN50J5200 TV that I'd like to get working with HA. I'll report back soon as I can.

quoting myself

i believe that the 5200 series TV's are not capable of being controlled remotely. you can confirm this by using the smartview application. the application will give you DLNA ability and media control. but you will not be able to do things like change the channel. or bring up the setup menu on the TV

quoting @firstof9

Verified with the SmartView app it detects the TV but no controls :( oh well.

H and J 5* series and lower TV's do not have the necessary software built onto the TV to accept a connection. You can test this if you want by using the SmartView application yourself. Port 8080 is the port the connection takes place on If you run a port scan you will see that port 8080 is not an open port. There is a guy that is attempting to get it working on these TV''s. He has managed to get the pin dialog up. managed to go through the whole authentication process (does not use port 8080 to do the authentication) but when it comes time to make the websocket connection.. it fails. He actually bricked his TV (boot looped) messing about in the extended service menu trying o turn on that port for connection.

my H series I have I believe is a 4200 series. and I am pretty sure it is going to suffer the same fate. It is simply because the firmware on the TV does not have the necessary software to take the connection..

Now... what you might be interested in doing is this. The mainboards for these TV's is pretty inexpensive 30-50 USD. I know with my D series the only difference between the 8000 series (this is what I have) and the 9000 series is the mainboard. I could buy a mainboard for a 9000 plug it in . and now I would have a 9000 series TV.

the panels are used on more then a single model. so you may be able to locate some information on a mainboard "upgrade" there could possibly be a mainboard for a higher model that will simply "plug in" to your existing TV. and thus giving you all of the features. I have not done the research on this to see f it is possible. maybe you can call samsung. IDK. If you can find a detailed photo of the board to be able to compare the connections to it.

the forum on sammygo is a good place to ask these kinds of questions as well.

@ThaStealth
you fall into the same bucket with the 5200 series J model... as what i outlined above..

Hi @kdschlosser.

This code connects succesfully with my H6400 Samsung: https://community.home-assistant.io/t/control-newer-samsung-tvs/29895/60?

The first time I have connected the TV I had to introduce a PIN. I can see the TV status on my HA, control the volume and mute, but the power on/off does not work.

Hi @sermayoral, How did you manage to enter the pin? Did you use command line? Can you please explain that part please?

@pablolassalle The code has a configurator that you can use to inter the PIN.

That' s correct @pablolassalle

@pablolassalle

that is actually incorrect. You never had to authenticat with the TV because that code only uses Volume, mute and sources by using UPNP. it is not capable of a remote websocket connection. and there for it will not power off the TV either. you will not have number entry for changing the channels. just mute volume and sources it appears. and that is only if the TV supports those UPNP functions It also does not take into account that different model and year TV's will us different UPNP services and also different function names. from the quick look over of the code it will only work on H and J series TV's

@kdschlosser Can I test this on Hassio ? because pip commands are invalid ....
(sorry for my ignorance)

I do not know what hassio is.

Fantastic, it's working today! On Linux. MU6100 TVs.
Things to note - I had to have the TVs turned on for first detection.
If they wern't on, it saved a config file for them with the legacy method, so probably good if it can not save the config file unless the connection is successful?

Mute doesn't work, setting volume steps works, setting volume directly doesn't nor does setting the source except for the HDMI button

Can't get it working on Windows though, looks to have issues detecting the MAC and it ignores the MAC from the media_players.yaml config file so can't manually specify it
2019-02-11 16:31:22 ERROR (SyncWorker_14) [samsungctl] Unable to acquire TV's mac address 2019-02-11 16:31:23 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform samsungtv Traceback (most recent call last): File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\site-packages\homeassistant\helpers\entity_platform.py", line 128, in _async_setup_platform SLOW_SETUP_MAX_WAIT, loop=hass.loop) File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\asyncio\tasks.py", line 358, in wait_for return fut.result() File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\concurrent\futures\thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\James\AppData\Roaming\.homeassistant\custom_components\media_player\samsungtv.py", line 111, in setup_platform [SamsungTVDevice(host, name, description, method, uuid, config_path)] File "C:\Users\James\AppData\Roaming\.homeassistant\custom_components\media_player\samsungtv.py", line 140, in __init__ self._config = samsungctl.Config() File "C:\Users\James\AppData\Roaming\.homeassistant\deps\Python36\site-packages\samsungctl\config.py", line 57, in __init__ raise exceptions.ConfigHostError samsungctl.exceptions.ConfigHostError: <unprintable ConfigHostError object>

I have most of the things you mentioned repaired. I will be pushing an update soon to samsungctl.
We are making progress, albeit slow but at least there is movement in the right direction :smile:

as far as the config goes. this is the hard part. because of the 10 second limitations that Home Assistant has in place it is making it difficult to really run a full detection suit. I think I have a way to go about it. that would be really fast and also I would be able to run all 3 detection types at the same time. this would greatly speed up the whole process.

I need the UPNP layout for the 2016+ TV's. I have for the legacy and for the encrypted once i get the one for the websocket connection II will be able to see which type has what UPNP services. I am willing to bet there is a single unique service to each of the TV types. and if that is the case then I can send out a broadcast for each of the connection types specifically. from there i can determine the connection by seeing who answered what broadcast.

If someone has a newer TV and also have Python installed you can clone this repo

https://github.com/kdschlosser/UPNP_Device/tree/develop

and run

python setup.py install

and once it is done installing make sure you have your TV on. and run this command

upnp_device --dump "[DUMP_DIRECTORY]" --timeout 10 [IP]

changing the [IP] to the ip of your TV and changing [DUMP_DIRECTORY] to the directory where you want copied of the UPNP files form the TV dumped into. make sire the directory already exists and it also has to be an absolute path so no $'s or ~'s or %'s

after it finished the directory is going to contain an exact replica of the UPNP paths that the TV has as well as a SSDP.log file. which is a log of the SSDP responses form the TV. I would need the whole directory zipped up exactly how it is.

I am going to do a commit shortly to update the code in the UPNP_Device repo. so you have to give me 15 minutes or so before trying it.

You can also test out setting the TV volume if you wanted. and getting the volume and setting the mute and getting the mute as well.

upnp_device --execute RenderingControl1.GetVolume --InstanceID 0
upnp_device --execute RenderingControl1.SetVolume --InstanceID 0 --DesiredVolume 50

there may be an additional parameter needed depending on the TV

upnp_device --execute RenderingControl1.GetVolume --InstanceID 0 --Channel Master
upnp_device --execute RenderingControl1.SetVolume --InstanceID 0 --Channel Master --DesiredVolume 50

Mute is pretty much the same deal. just swap out Volume for Mute and you have to specify a 1 or a 0 for the value if setting it.

when you do the dump you will see a whole printout of every upnp function the TV offers. if you want to do that without dumping the data

upnp_device [IP]

if you omit thee IP it is going to print out every device on your network.

you can also get help on a specific function. this is going to tell you the arguments that are required and ones that are optional. default values. choices. min and max. crap like that

upnp_device --execute RenderingControl1.SetVolume --help

the --help MUST be after the function

Here is from a websocket TV
https://www.dropbox.com/s/c75jwb8b3gahtv2/MU6300_upnp.zip

I did get an error
Finding UPNP Devices please wait.................................
Traceback (most recent call last):
File "C:UsersJamesAppDataLocalProgramsPythonPython36-32Scriptsupnp_device-script.py", line 11, in
load_entry_point('UPNP-Device==0.1.0b0', 'console_scripts', 'upnp_device')()
File "C:UsersJamesAppDataLocalProgramsPythonPython36-32libsite-packagesupnp_device-0.1.0b0-py3.6.eggUPNP_Device__main__.py", line 118, in main
print(dvc)
File "C:UsersJamesAppDataLocalProgramsPythonPython36-32libsite-packagesupnp_device-0.1.0b0-py3.6.eggUPNP_Deviceupnp_class.py", line 199, in __str__
output = 'nn' + str(self.__name__) + 'n'
File "C:UsersJamesAppDataLocalProgramsPythonPython36-32libsite-packagesupnp_device-0.1.0b0-py3.6.eggUPNP_Deviceupnp_class.py", line 176, in __getattr__
raise AttributeError(item)
AttributeError: __name__

@kdschlosser first of all; thanks for taking the time to look into this!
I have a 2018 tv at home, will try to get you the requested details on the upnp layout tonight.

Here's a dump from an 2018 websocket TV: NU8006.zip
Running the script brought my server (4-core i5) to its knees, don't know if this is a sign of any issues...

It did everything it is supposed to.

The UPNP side of things runs a crap load of threads. I have it do this so it can scan your whole network for UPNP devices in about 3-5 seconds. add that along with building the class representations which consists of repeated connections to the device to get the files needed. the locations of each file or inside of a file and inside of the file that you were just pointed to. kind of like one of those matryoshka dolls. (nesting doll). UPNP is a crappy specification and horribly slow because of how it is designed. then add all that to writing all the data to disk.. so yeah.. it can be pretty taxing to a computer for all of about 10 seconds.

BTW. I updated the code in the first post and also updated the samsungctl develop branch. I am running at 100% with my legacy TV. everything is functioning. starting HASS with the TV off. starting it with the TV on turning it off and on while HASS is running. it populates thee sources properly. and selecting the sources works. mute now works. on and off as well as thee status, the volume slider and buttons also work correctly.

Power works properly when pressing the buttons in hass as well as when pressing directly on the TV.

I got rid of all of those timeeout warnings.

Oh as an added thing. I also added application support for the websocket based TV's SURPRISE!!! it is going to list the applications in thee sources list.. :smile: it is also going to remove all of the other sources that do not function. Unfortunately because I have not quite figured out how to go about getting the source from the TV just yet. I am only able to show the source that is currently on if it is an application.

I will be adding application content at some point as well. The library can already do it. it's just a matter if getting the information into hass.

I do have a question maybe someone may have an answer to. I know an image can be set to he application (not an icon but an image in that blue bar in the default hass UI). I can only find reference to passing a URL as the actual "image", the image data is gotten over the websocket connection as a base64 encoded string (or bytes). I have tried to return this string.. and no go. it hangs home assistant. is there a way to return the image as a string from the entity_picture property?

also if you go into the actual control for samsungctl. the little icon that shows there to thee left of the name. it changes with you changing the source including some of the more popular applications like Netflix, Amazon, Hulu.......

So, I started testing the component to my production system now and here are few issues that I encountered:

  1. name in config is not being used. I have the following in my config:
  - platform: samsungtv
    host: 192.168.2.252
    name: Living Room TV

The entity that is created is media_player.samsungctl.

  1. On this system, the status is not detected properly. The entity says off, even when the TV is off. I was able to turn on the tv from HA, but it stayed `off. I see this in the log:
2019-02-11 09:30:34 DEBUG (SyncWorker_27) [custom_components.media_player.samsungtv] Samsung TV 192.168.2.252 added as 'Living Room TV'
2019-02-11 09:30:39 ERROR (Thread-14) [websocket] close status: 31522
2019-02-11 09:30:49 DEBUG (SyncWorker_11) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-11 09:30:59 DEBUG (SyncWorker_13) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-11 09:31:10 DEBUG (SyncWorker_1) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off

When I try to power on the TV from inside HA, the TV turns on, but it still shows as off in HA. Here are the logs:

019-02-11 09:33:11 DEBUG (SyncWorker_6) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-11 09:33:22 DEBUG (SyncWorker_12) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-11 09:33:33 DEBUG (SyncWorker_23) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-11 09:33:34 DEBUG (Thread-115) [custom_components.media_player.samsungtv] samsungctl TV: Power on process started
2019-02-11 09:33:34 DEBUG (SyncWorker_22) [custom_components.media_player.samsungtv] samsungctl TV: Powering On
2019-02-11 09:33:43 DEBUG (SyncWorker_14) [custom_components.media_player.samsungtv] samsungctl TV: Powering On
2019-02-11 09:33:54 DEBUG (SyncWorker_1) [custom_components.media_player.samsungtv] samsungctl TV: Powering On
2019-02-11 09:34:05 DEBUG (SyncWorker_23) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-11 09:34:16 DEBUG (SyncWorker_35) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off

So, I looked at the .conf file that was saved and here is the one on the system that is not working correctly:

description = aloknuc
host = 192.168.2.252
port = 8002
id = None
method = websocket
timeout = 0
token = None
device_id = None
upnp_locations = None
paired = False
mac = MAC
name = samsungctl

The other one, which is working correctly:

description = homeassistant
host = 192.168.2.252
port = 8002
id = None
method = websocket
timeout = 0
token = 85227270
device_id = None
upnp_locations = None
paired = True
mac = MAC
name = Living Room TV

SO, I manually deleted the file and restarted HA, but the new conf file was similar to the old one.

I noticed the config issue as well. It is not a big deal because this only gets used for thee actual connection to the TV. thee name that takes presidence and shows in your home assistant GUI is the on that is supplied in the home assistant config file. so it is pretty moot.

That is strange about the power state for the TV. I am going to put the code back to use the socket as the mechanism to determine the state of the TV. I like this mechanism better then making another call to the TV to see if it returns data.

I am guessing you are not able to test anything because the TV s reported as being off.

let me make a quick change and see if it solves your problem

ok library is updated. and so is the code in the first post.

Still the same...I don't get why paired = False and there is no token in one of the configs even after I allowed it on the TV.

I also tried to manually edit the config file to add the token and change paired = True, but it still did not work.

hi,
using the latest code it detects the tv yet it doesn't allow me to turn on and it doesn't show its true state

here is the config

description = homeassistant
host = .uyip
port = 8002
id = None
method = websocket
timeout = 0
token = None
device_id = None
upnp_locations = None
paired = False
mac = mymac
name = samsungctl

Good...so it is not just me :) It was working in one of the earlier versions.

Agreed about 3 version back I was able to adjust the volume and turn off/on Was a little hit n miss.
Yet now nothing.

Very much looking forward to having this working.

Seems like it isn't authenticating properly after updating (testing on Windows sorry)

2019-02-12 10:45:24 DEBUG (SyncWorker_10) [root] RemoteWebsocket.power()
2019-02-12 10:45:34 WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.cafe_samsung1 is taking over 10 seconds
2019-02-12 10:45:35 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv media_player took longer than the scheduled update interval 0:00:10
2019-02-12 10:45:43 ERROR (Thread-7) [websocket] close status: 31522
2019-02-12 10:45:43 DEBUG (SyncWorker_10) [root] RemoteWebsocket.power => True
Exception in thread Thread-7:
Traceback (most recent call last):
  File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\James\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\James\AppData\Roaming\.homeassistant\deps\Python36\site-packages\samsungctl\websocket_base.py", line 70, in loop
    if self.open():
  File "C:\Users\James\AppData\Roaming\.homeassistant\deps\Python36\site-packages\samsungctl\utils.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\James\AppData\Roaming\.homeassistant\deps\Python36\site-packages\samsungctl\remote_websocket.py", line 164, in open
    raise RuntimeError('Auth Failure')
RuntimeError: Auth Failure

2019-02-12 10:45:43 DEBUG (SyncWorker_10) [custom_components.media_player.samsungtv] Cafe Samsung1 TV: Power is Off
2019-02-12 10:45:43 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.cafe_samsung1, old_state=<state media_player.cafe_samsung1=unknown; volume_level=0.0, is_volume_muted=False, source=, source_list=[], friendly_name=Cafe Samsung1, icon=mdi:television-off, supported_features=20413 @ 2019-02-12T10:45:13.170883+13:00>, new_state=<state media_player.cafe_samsung1=off; friendly_name=Cafe Samsung1, icon=mdi:television-off, supported_features=20413 @ 2019-02-12T10:45:43.787436+13:00>>
2019-02-12 10:45:43 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.131010896] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'media_player.cafe_samsung1', 'old_state': <state media_player.cafe_samsung1=unknown; volume_level=0.0, is_volume_muted=False, source=, source_list=[], friendly_name=Cafe Samsung1, icon=mdi:television-off, supported_features=20413 @ 2019-02-12T10:45:13.170883+13:00>, 'new_state': <state media_player.cafe_samsung1=off; friendly_name=Cafe Samsung1, icon=mdi:television-off, supported_features=20413 @ 2019-02-12T10:45:43.787436+13:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 11, 21, 45, 43, 787436, tzinfo=<UTC>), 'context': {'id': '0234e318aed14aaab0a6c50e59269777', 'user_id': None}}}
2019-02-12 10:45:46 DEBUG (SyncWorker_6) [root] RemoteWebsocket.power()
2019-02-12 10:45:46 DEBUG (SyncWorker_6) [root] RemoteWebsocket.power => True
2019-02-12 10:45:46 DEBUG (SyncWorker_6) [custom_components.media_player.samsungtv] Cafe Samsung1 TV: Power is Off
2019-02-12 10:45:56 DEBUG (SyncWorker_24) [root] RemoteWebsocket.power()
2019-02-12 10:45:56 DEBUG (SyncWorker_24) [root] RemoteWebsocket.power => True
2019-02-12 10:45:56 DEBUG (SyncWorker_24) [custom_components.media_player.samsungtv] Cafe Samsung1 TV: Power is Off
2019-02-12 10:46:06 DEBUG (SyncWorker_13) [root] RemoteWebsocket.power()
2019-02-12 10:46:06 DEBUG (SyncWorker_13) [root] RemoteWebsocket.power => True
2019-02-12 10:46:06 DEBUG (SyncWorker_13) [custom_components.media_player.samsungtv] Cafe Samsung1 TV: Power is Off
2019-02-12 10:46:16 DEBUG (SyncWorker_7) [root] RemoteWebsocket.power()
2019-02-12 10:46:16 DEBUG (SyncWorker_7) [root] RemoteWebsocket.power => True
2019-02-12 10:46:16 DEBUG (SyncWorker_7) [custom_components.media_player.samsungtv] Cafe Samsung1 TV: Power is Off
2019-02-12 10:46:27 DEBUG (SyncWorker_28) [root] RemoteWebsocket.power()
2019-02-12 10:46:27 DEBUG (SyncWorker_28) [root] RemoteWebsocket.power => True
2019-02-12 10:46:27 DEBUG (SyncWorker_28) [custom_components.media_player.samsungtv] Cafe Samsung1 TV: Power is Off

Regarding media thumbnail/image, happy to figure that out when I can get it working on my dev laptop. Looks like it will probably have to be written out to a file then proxied through to Home Assistant; which is weird because the front end loads it through as Base64 from what I can tell

Can someone please help me? I am getting this error when I restart HA.

Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/samsungtv.py", line 99, in setup_platform
    import samsungctl
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl/__init__.py", line 20, in <module>
    from .remote import Remote # NOQA
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl/remote.py", line 5, in <module>
    from .remote_legacy import RemoteLegacy
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl/remote_legacy.py", line 10, in <module>
    from . import upnp
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl/upnp/__init__.py", line 5, in <module>
    from lxml import etree
ImportError: libxslt.so.1: cannot open shared object file: No such file or directory

What I did is:
1- uninstall samsungctl as described in the first post.
2- install the samsungctl using the command line described on the first post
3- added the code in my configuration.yaml

media_player:
  - platform: samsungtv
    host: 192.168.1.58
    method: encrypted #(I have tried with and without this line)

Any hint will be more than welcome.

Thanks

@pablolassalle You may have to install the dependencies manually. For Ubuntu, apt-get install libxml2-dev libxslt1-dev python-dev should work.

Thanks @arsaboo. Should I install this on the HA virtualenv?

Yes in the virtualenv

finally was able to try this and I copied the code and I can see the popup on my TV but nothing works on the TV (its also not using the name from the file but someone else reported that.)

samsung file

description = Tower
host = 192.168.1.218
port = 8001
id = None
method = websocket
timeout = 0
token = None
device_id = None
upnp_locations = None
paired = False
mac = 64:1c:b0:f4:c8:32
name = samsungctl

configuration.yaml

platform: samsungtv
name: Samsung Living Room
host: !secret living_room_tv_ip

And my log file with the new components set to debug (which IIRC is the lowest log level so should catch everything.)

2019-02-13 20:56:21 WARNING (MainThread) [homeassistant.loader] You are using a custom component for custom_updater which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-13 20:56:23 ERROR (SyncWorker_11) [homeassistant.components.sensor.waze_travel_time] Unable to find entity device_tracker.owntracks_matt
2019-02-13 20:56:23 ERROR (SyncWorker_11) [homeassistant.components.sensor.waze_travel_time] Unable to find entity sensor.dest_address
2019-02-13 20:56:24 INFO (SyncWorker_88) [custom_components.media_player.samsungtv] Samsung TV 192.168.1.218 added as 'Samsung Living Room'
2019-02-13 20:56:35 DEBUG (SyncWorker_107) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:56:46 DEBUG (SyncWorker_101) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:56:57 DEBUG (SyncWorker_84) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:56:59 ERROR (SyncWorker_110) [homeassistant.components.wemo] Unable to get description url for WeMo at: 192.168.1.60
2019-02-13 20:57:08 DEBUG (SyncWorker_32) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:57:19 DEBUG (SyncWorker_101) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:57:27 ERROR (SyncWorker_110) [homeassistant.components.wemo] Unable to get description url for WeMo at: 192.168.1.61
2019-02-13 20:57:30 DEBUG (SyncWorker_17) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:57:41 DEBUG (SyncWorker_91) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off
2019-02-13 20:57:52 DEBUG (SyncWorker_118) [custom_components.media_player.samsungtv] samsungctl TV: Power is Off

My TV was on the whole time. I have a UN43NU6900 and can control it from smartthings (on and off at least haven't tried other controls from that) So I'd think I can control it from this.

let me know if there is any other info you need.

I am trying to get this blasted thing to display some kind of an entry form. I have redesigned the whole discovery process. it is much faster, and the detection of the TV's works better. since there is a UPNP scan that has to take place i am able to use the UPNP service classes to define what connection method needs to get used. I also wanted to use this same mechanism to add TV's to Home Assistant. I do not know if there is a way to dynamically add "entity's" while the program is running. or can it only be done on startup. How do I invoke a dialog to appear to allow the user to enter a pin for the TV. or a name for the TV?

I am spending way to much time trying to figure this stuff out. I have to many other projects that require my attention. I am finding Home Assistant to be very unstable. I get random errors sometimes. ones that have nothing to do with trying to add this to Home Assistant. Sometimes it seems to hang for 5-8 minutes on startup for no apparent reason. I moved the saving of the config file to somewhere else in the code and now it saves properly... why?.. what is interfering with it being written?

the mechanics of the updating of the states makes absolutely no sense to me, I do not understand why pile all of the status updates into a single method and then complain that it takes to long to finish updating them. In an ideal world a device would respond instantly. Any time you deal with any kind of a device that has a UI and can be controlled over the network. the UI is going to take priority. and with how the manufacturers are real tight when it comes to available resources that makes things take even longer. Forget about adding application support. querying a TV for it's application list can take upwards of 4-5 seconds to do. and then if i wanted to grab the icon for each application there goes another second per application. 30 installed applications = 35 seconds to update just that! and then if we toss content on top of that. oh lord!..

why is there even that small of a timeout when storing the states anyway? does the program get held up during this time?

because of the nature of the code in hass an IDE is pretty much useless. It can't follow the data path at all. So there is no help there.

I am thinking at this juncture I have not the want to spend the time to try and figure this thing out. I have spent enough time messing about with. Maybe there is someone else that has the knowledge to get it running properly. All I can say is that the library works outside of using it in Home Assistant.

We all appreciate the effort you are making.

Much encouragement! The code is almost ready. In some TVs almost everything works in Home Assistant with your code.

Maybe you should work with someone who knows the Home Assistant code well. Does anyone know any of the samsungtv developers?

Thanks for everything!

I agree with the above
Maybe it's worth posting on the HA fourm to reach a larger audience.

I’ve just installed this and followed the instructions exactly as per the first post. My UA60H6400 just won’t show up in HA. I’m not sure what is wrong as there are no errors, only that it can’t find the MAC address. If I define the MAC address, there is no errors at all.

I’ve just installed this and followed the instructions exactly as per the first post. My UA60H6400 just won’t show up in HA. I’m not sure what is wrong as there are no errors, only that it can’t find the MAC address. If I define the MAC address, there is no errors at all.

Where do you define de MAC address? In the configuration.yaml file in that way?

  • platform: samsungtv
    host:
    name: Living Room TV
    method: encrypted
    mac:

Where do you define de MAC address? In the configuration.yaml file in that way?

Yep. This is what I have.

  - platform: samsungtv
    host: 192.168.1.64
    name: UA60H6400
    mac: <mac_address> # obviously I have the correct MAC address
    method: encrypted

Samaungctl ignores the MAC. Have you tried making sure the TV is on when starting Home Assistant and ensure there are no config files in the Samsungctl folder
Also checking are you running it on Windows or Linux?

Really hoping someone can get this working. I wish I was more versed in HA and all its quirks so I could look into it.

We should greatly simplify the component and add one feature at a time. IN any case, the component is broken in 0.88 as it has to be moved to the embedded format.

@sermayoral I am the developer of samsungctl.
@cjsmns you problem exists because you have an H series TV. this TV requires the entry of a PIN. this PIN gets displayed on the TV and you will need to enter it into hass. the problem is I cannot get any kind of a dialog or some kind of an input field to display so you can enter the pin. the pin is randomly generated at initial connection and has to be entered while the program is running.

The MAC address ONLY gets used for turning the TV on. and nothing more. if you are having a problem with the TV getting turned on and the initial connection is done. there will b a folder where the config yaml file is located called samsung_tv in there will be a file that has the IP address of the TV for the name. edit that file. there will be a line for the mac address. the mac address gets automatically discovered. if it does not or there is an error. please tell me what the error is. the TV does need to be turned on when you initially add the TV to Home Assistant.

@arsaboo I can't get past step one. getting the TV's added properly. There needs to be a settings page for the TV. things that can be adjusted at run time. not before or after. it has to take place while the program is running.

Is this pin generated every session or is it done once and stored? If it's the latter the initial setup could possibly be done through Home Assistant's integration menu..?

it is not stored. and yes it is only done once on initial connection. I used the cod from the braviatv media_player component as a guide. I made it so that a dialog would be opened for every TV to see if I could get it to open. and it never does. the callback never gets called.

ok i finally found where they are hiding that damned configuration dialog. it comes in as a notification instead of either in a device configuration page or as a simple popup

OK I updated the code in the first post.

READ THE ENTIRE FIRST POST AGAIN.
there is much that has changed, for the better I hope.

THIS COMPONENT IS NOW WORKING 100% FOR LEGACY TV'S (<= 2013)

@Skeletorjus

The pin portion still needs work. After adding a TV you will now get a notification to enter the PIN (it will be in your notifications). I also changed up some of the encrypted code. So give it a test run and see if it works.

@arsaboo

as far as this statement goes..

the component is broken in 0.88 as it has to be moved to the embedded format.

Not exactly sure what you mean,..

This is what I did. I downloaded and installed Python 3.7. then i ran

pip install homeassistant

edited the file

\PYTHON_INSTALL_PATH\lib\site-packages\homeassistant\components\media_player\samsungtv.py

replaced the contents of the file with the code that is in the first post. nothing fancy..

@kdschlosser From the release notes:

Note for custom component developers: We are moving to a new file structure. Platforms now live embedded in components. Custom platforms will have to be updated to follow this pattern. This is a breaking change in case your custom platform overrides a built-in platform. Rename your custom platform from, ie light/hue.py to hue/light.py.

hi
ive updated and done as you suggested yet it doesn't detect my tv. it creates a folder but doesn't place any file in it

@kdschlosser thanks for replying. I've updated the code and removed everything so now I only have
- platform: samsungtv.

I've deleted the .noinclude file and started again. I've got the first notification box to show up to enter in name, description, and mac, but then the next notification to enter in the pin, well, nothing shows up on my TV, so I don't know what the PIN is.

This notification in now constantly there, no way to remove it even though it's missed the timeout. There is also no file created. Only fix is to restart HA.

Also, that 60 second timeout is rather short. Sometimes I've had a .noinclude file created before the HA frontend has loaded, so I can't do anything, sometimes it times out a bit later, so I can click the notification, but then it times out. Is this timeout on the TV or part of samsungctl?

Also, you should not edit HA files directly. Instead, you can use custom_components. For example, in this case, you can use custom_components\media_player\samsungtv.py. The custom_components folder should be created in the same location as your configuration.yaml file.

this is not something that is going to be an "add on" for lack of better words. This is to test code that will be submitted as a replacement to the already existing samsungtv.py file. so in that context it should be tested as such. a replacement. not an add on/custom component.

I know, but there is no difference between editing the file and using custom_components.

using custom_components is how ive been testing this

@phairplay

ok now here comes the dumb question. Is the TV on?

@arsaboo
Yes there is a difference. if there was no difference the how would hass know the custom-components file even exists?? so there is something in the backend mechanics of hass that handles this and it gets loaded through a different set of instructions then the one that is in the componentsmedia_player folder. I do not know how the file is handled or how the module gets stored. I do know that I am testing this in the same context that it will hopefully get used in. If for some reason there is a bug in the custom_components sections... Oh wait.. there is a bug in it isn't there??? OK so back to my point. replace the samsungtv.py file in the componentsmedia_player folder. make a backup of the original first.

and the bug in the custom_components does not effect the components correct??

@kdschlosser See https://developers.home-assistant.io/docs/en/creating_component_loading.html

custom_components is loaded first and overrides the built-in component.

@kdschlosser
lol yes its on.

did you read..

Note that overriding built-in components is not recommended and will probably break things!

it's right there.. NOT RECOMMENDED

also I changed the code in the first post. it now has a 5 minute timeout on the notification.

@kdschlosser has right. This wont be a custom component, so we are going to test in the components/media_player folder, just in case.

It is almost ready 😊

@phairplay

add this to your configuration.yaml file

logger:
  default: debug
  logs:
    components.media_player.samsungtv: debug
    samsungctl: debug

then run home assistant and copy the ENTIRE output and save it to a file.

here is an invite link to slack chat. you cen send me the file directly that way.
https://join.slack.com/t/samsungtvcontrol/shared_invite/enQtNTUzMDQ4ODY1MDk0LTA0Yjk3OTIwZWM0ODdmODFiMGEyNzg1OTBlZWI2YzEyYzNiMThiOTg0MDQxNDJiMjRlN2RiMDYzY2UzNjQwNTg

just in case there is sensitive information you do not want to share.

let home assistant run for a minute or 2 before copying the output

there isnt anything in the logs

2019-02-14 22:13:22 WARNING (MainThread) [homeassistant.components.http] legacy_api_password support has been enabled. If you don't require it, remove the 'api_password' from your http config.
2019-02-14 22:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.samsungtv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-14 22:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.androidtv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-14 22:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for notify.pushover_ha which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-14 22:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.tautulli which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-14 22:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.hue which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-02-14 22:13:29 WARNING (SyncWorker_7) [pyhik.hikvision] Sensor type "audioexception" is unsupported.
2019-02-14 22:13:29 WARNING (SyncWorker_7) [pyhik.hikvision] Sensor type "audioexception" is unsupported.
2019-02-14 22:13:29 WARNING (SyncWorker_7) [pyhik.hikvision] Sensor type "audioexception" is unsupported.
2019-02-14 22:13:29 WARNING (SyncWorker_7) [pyhik.hikvision] Sensor type "audioexception" is unsupported.
2019-02-14 22:13:53 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Current Activity, the state is unknown.
logger:
    default: warning
    logs:
      custom_components.media_player.samsungtv: debug
      samsungctl: debug
media_player:
  - platform: samsungtv

humor me on this. do not run this as a custom component. replace the contents of componentsmedia_playersamsungtv.py with the code from the first post.

add this to your configuration.yaml file (at the bottom)

logger:
    default: debug  <==== THIS HAS TO STAY AS DEBUG
    logs:
      components.media_player.samsungtv: debug
      samsungctl: debug

@phairplay, please, do not use a custom_component.

@kdschlosser. To test the samsungtv.py component. Is it no longer necessary to update the samsungctl component?

i'm running hassio so i'm not able to access the main home assistant file, so only have the option to run as a custom

could this be the cause of the issue?

the code form the first post will update samsungctl if necessary. all you need to do is a simple copy and paste into the componentsmedia_playersamsungtv.py file. you have to delete all of the code currently in the file and then paste in the new code.

@phairplay

i do not know. it states in the docs that overriding a component using custom_components can cause problems. the extent of the problems i do not know.

if there any way you can install Python and do a simple

pip install homeassistant

better if you use a different computer to do this. i do not want it making changes to your current configuration.

no i'm running the locked down version of HA hass.io i don't have another set to run the open version of HA
i think ill have to drop out testing this

@kdschlosser custom components are not recommended as they are not tested. Other than that there is no difference.

@phairplay you can test it under /config/custom_component/media_player/samsungtv.py

@arsaboo
thats what i was doing

Ok. I'm going to test under /components (not custom). so we have more precision

I am going to follow the instructions of the documentation that states it is not recommended to do and that it will probably break things.

If it was OK to do they would say it works perfectly and that it doesn't break anything. that isn't the case.

I do not know what happens with the logging output when running hass.io because even if i start hass without debugging enabled after 2 minutes with nothing installed i have 3-4 pages of logging information. with debugging enabled @phairplay is only getting a few lines. so it's doing something different.

and I will mention not a single one of those lines is debugging output from samsungctl.

its acting like the component is not even being run. or th one that is in the components is being run instead. I guess we can test this theory..

add

media_player:
  - platform: samsungtv
    host: 192.168.1.1

to your home assistant configuration.yaml file.

if something then changes in the logging output it is 100% NOT from the new code.

@kdschlosser

yeah i noticed i didn't have the logger set correctly i use it to block a chrome error so it was set to warning not debug,

i corrected this but didn't post it as it seems my issue maybe related to me using it as a custom component instead of the main component

@phairplay
I edited my last post.

also.. enable the debug for the default. I need to see what is happening. without that information I am kind of stuck

you should see information like this in the log

2019-02-14 15:49:54 DEBUG (Thread-354) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.201
2019-02-14 15:49:54 DEBUG (Thread-354) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age = 1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.201:52235/dmr/SamsungMRDesc.xml",
    "SERVER": "Linux/9.0 UPnP/1.0 PROTOTYPE/1.0",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:2c782d5f-9fd1-9152-41e1-0af79c23d484::urn:schemas-upnp-org:device:MediaRenderer:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-14 15:49:54 DEBUG (Thread-357) [UPNP_Devices] SSDP: 192.168.1.201
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 15:49:54 DEBUG (Thread-357) [UPNP_Devices] SSDP: 192.168.1.201
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 15:49:54 DEBUG (Thread-357) [UPNP_Devices] SSDP: 192.168.1.201
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 15:49:54 DEBUG (Thread-357) [UPNP_Devices] SSDP: 192.168.1.201
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 15:49:54 DEBUG (Thread-357) [UPNP_Devices] SSDP: 192.168.1.201
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 15:49:54 DEBUG (Thread-354) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.201
2019-02-14 15:49:54 DEBUG (Thread-354) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age = 1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.201:52235/MainTVServer2/MainTVServer2Desc.xml",
    "SERVER": "Linux/9.0 UPnP/1.0 PROTOTYPE/1.0",
    "ST": "urn:samsung.com:device:MainTVServer2:1",
    "USN": "uuid:1b0d8e6e-30cf-1f9e-f1fb-2f30e82f6be7::urn:samsung.com:device:MainTVServer2:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-14 15:49:54 DEBUG (Thread-354) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.201
2019-02-14 15:49:54 DEBUG (Thread-354) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age = 1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.201:52235/rcr/RemoteControlReceiver.xml",
    "SERVER": "Linux/9.0 UPnP/1.0 PROTOTYPE/1.0",
    "ST": "urn:samsung.com:device:RemoteControlReceiver:1",
    "USN": "uuid:2007e9e6-2ec1-f097-f2df-944770ea00a3::urn:samsung.com:device:RemoteControlReceiver:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-14 15:49:55 DEBUG (Thread-357) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.201
2019-02-14 15:49:55 DEBUG (Thread-357) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age = 1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.201:52235/dmr/SamsungMRDesc.xml",
    "SERVER": "Linux/9.0 UPnP/1.0 PROTOTYPE/1.0",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:2c782d5f-9fd1-9152-41e1-0af79c23d484::urn:schemas-upnp-org:device:MediaRenderer:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-14 15:49:55 DEBUG (Thread-357) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.201
2019-02-14 15:49:55 DEBUG (Thread-357) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age = 1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.201:52235/MainTVServer2/MainTVServer2Desc.xml",
    "SERVER": "Linux/9.0 UPnP/1.0 PROTOTYPE/1.0",
    "ST": "urn:samsung.com:device:MainTVServer2:1",
    "USN": "uuid:1b0d8e6e-30cf-1f9e-f1fb-2f30e82f6be7::urn:samsung.com:device:MainTVServer2:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-14 15:49:55 DEBUG (Thread-357) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.201
2019-02-14 15:49:55 DEBUG (Thread-357) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age = 1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.201:52235/rcr/RemoteControlReceiver.xml",
    "SERVER": "Linux/9.0 UPnP/1.0 PROTOTYPE/1.0",
    "ST": "urn:samsung.com:device:RemoteControlReceiver:1",
    "USN": "uuid:2007e9e6-2ec1-f097-f2df-944770ea00a3::urn:samsung.com:device:RemoteControlReceiver:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}

try samsungctl: info

NO debug. otherwise there will not be the correct output

@phairplay In Hass.io the samsungctl component may not be updating, just as you cannot edit the component / media_player / samsungtv.py.

Hass.io is a Docker, so it is very restricted

`2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=script>
2019-02-14 22:56:48 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 INFO (MainThread) [homeassistant.loader] Loaded hue.light from homeassistant.components.hue.light
2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.nmap_tracker
2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 INFO (SyncWorker_19) [homeassistant.components.device_tracker.nmap_tracker] Scanner initialized
2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.bluetooth_tracker
2019-02-14 22:56:48 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.184
2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=group, service=set, service_data=object_id=all_scripts, name=all scripts, visible=False, entities=['script.get_david', 'script.nightlight_alexander', 'script.morningwakeup_alexander', 'script.bbcnews', 'script.bbcone', 'script.bbctwo', 'script.clean_plex', 'script.five', 'script.four', 'script.homealarm_on', 'script.lightdownstairs_off', 'script.lightdownstairs_on', 'script.manaul_backup', 'script.manaul_google_upload', 'script.wakeup_master_bedroom', 'script.morning_workout_alarm', 'script.nzbget_pause', 'script.nzbget_resume', 'script.reboot_htpc', 'script.stop_plex_streams', 'script.tv_not_home_off', 'script.tv_not_home_on', 'script.kindle_update', 'script.update_plex_cartoons', 'script.update_plex_movies', 'script.cbbc', 'script.cctv_notice', 'script.download', 'script.goodnight', 'script.homesos', 'script.house_temperature_readout', 'script.itv', 'script.kitchenspotlights', 'script.morning_radio', 'script.morninginfo', 'script.plexpause', 'script.plexplay', 'script.plex_updated', 'script.plexwatch', 'script.shieldtest', 'script.skynews', 'script.plexstop', 'script.tvvolumedown', 'script.tvvolumeup', 'script.weather']>
2019-02-14 22:56:48 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=80",
    "DATE": "Thu, 14 Feb 2019 22:56:48 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.184:49153/description.xml",
    "SERVER": "Linux/4.9.109-tegra-g2dafed3, UPnP/1.0, Intel SDK for UPnP devices /1.2",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:898f9738-d930-4db4-a3cf-00044ba3e199::urn:schemas-upnp-org:device:MediaRenderer:1",
    "TYPE": "response"
}
2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.auto_lights_on_coming_home_wifi_bluetooth_trigger initial state True from recorder last state <state automation.auto_lights_on_coming_home_wifi_bluetooth_trigger=on; friendly_name=auto lights on coming home wifi/bluetooth trigger, hidden=True, last_triggered=2019-02-14T16:59:59.098053+00:00 @ 2019-02-14T22:52:32.399292+00:00>
2019-02-14 22:56:48 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.auto_lights_on_coming_home_wifi_bluetooth_trigger, old_state=None, new_state=<state automation.auto_lights_on_coming_home_wifi_bluetooth_trigger=off; last_triggered=2019-02-14T16:59:59.098053+00:00, friendly_name=auto lights on coming home wifi/bluetooth trigger, hidden=True @ 2019-02-14T22:56:48.884328+00:00>>
2019-02-14 22:56:48 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.184
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.auto_lights_on_coming_home_motion initial state True from recorder last state <state automation.auto_lights_on_coming_home_motion=on; friendly_name=auto lights on coming home motion, hidden=True, last_triggered=2019-02-11T16:56:21.186854+00:00 @ 2019-02-14T22:52:32.404440+00:00>
2019-02-14 22:56:48 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.184
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.auto_lights_on_coming_home_motion, old_state=None, new_state=<state automation.auto_lights_on_coming_home_motion=off; last_triggered=2019-02-11T16:56:21.186854+00:00, friendly_name=auto lights on coming home motion, hidden=True @ 2019-02-14T22:56:48.915678+00:00>>
2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.174
2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.lights_off_if_the_sun_is_up initial state True from recorder last state <state automation.lights_off_if_the_sun_is_up=on; friendly_name=lights off if the sun is up, hidden=True, last_triggered=2019-02-14T13:29:30.231870+00:00 @ 2019-02-14T22:52:32.411708+00:00>
2019-02-14 22:56:48 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.184
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Thu, 14 Feb 2019 22:56:48 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.174:9197/dmr",
    "SERVER": "Samsung-Linux/4.1, UPnP/1.0, Samsung_UPnP_SDK/1.0",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:f3d96ac7-ee5b-4445-b7aa-20e52e540f9b::urn:schemas-upnp-org:device:MediaRenderer:1",
    "CONTENT-LENGTH": "0",
    "BOOTID.UPNP.ORG": "27",
    "TYPE": "response"
}
2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.lights_off_if_the_sun_is_up, old_state=None, new_state=<state automation.lights_off_if_the_sun_is_up=off; last_triggered=2019-02-14T13:29:30.231870+00:00, friendly_name=lights off if the sun is up, hidden=True @ 2019-02-14T22:56:48.940687+00:00>>
2019-02-14 22:56:48 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.184
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.lights_off_cloud_coverage initial state True from recorder last state <state automation.lights_off_cloud_coverage=on; friendly_name=lights off cloud coverage, hidden=True, last_triggered=2019-02-14T13:33:47.063991+00:00 @ 2019-02-14T22:52:32.417074+00:00>
2019-02-14 22:56:48 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.184
2019-02-14 22:56:48 DEBUG (Thread-9) [UPNP_Devices] SSDP: 192.168.1.174
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.lights_off_cloud_coverage, old_state=None, new_state=<state automation.lights_off_cloud_coverage=off; last_triggered=2019-02-14T13:33:47.063991+00:00, friendly_name=lights off cloud coverage, hidden=True @ 2019-02-14T22:56:48.996454+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.184
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=80",
    "DATE": "Thu, 14 Feb 2019 22:56:48 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.184:49153/description.xml",
    "SERVER": "Linux/4.9.109-tegra-g2dafed3, UPnP/1.0, Intel SDK for UPnP devices /1.2",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:898f9738-d930-4db4-a3cf-00044ba3e199::urn:schemas-upnp-org:device:MediaRenderer:1",
    "TYPE": "response"
}
2019-02-14 22:56:49 DEBUG (Thread-9) [UPNP_Devices] SSDP: 192.168.1.174
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.morning_light_if_dark initial state True from recorder last state <state automation.morning_light_if_dark=on; friendly_name=morning light if dark, hidden=True, last_triggered=2019-02-14T06:45:21.368502+00:00 @ 2019-02-14T22:52:32.422133+00:00>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.174
2019-02-14 22:56:49 DEBUG (Thread-9) [UPNP_Devices] SSDP: 192.168.1.174
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.morning_light_if_dark, old_state=None, new_state=<state automation.morning_light_if_dark=off; last_triggered=2019-02-14T06:45:21.368502+00:00, friendly_name=morning light if dark, hidden=True @ 2019-02-14T22:56:49.035433+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Thu, 14 Feb 2019 22:56:48 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.174:7678/nservice/",
    "SERVER": "Samsung-Linux/4.1, UPnP/1.0, Samsung_UPnP_SDK/1.0",
    "ST": "urn:dial-multiscreen-org:device:dialreceiver:1",
    "USN": "uuid:20dc570e-d031-4afa-bcc9-84f520a9ccc3::urn:dial-multiscreen-org:device:dialreceiver:1",
    "CONTENT-LENGTH": "0",
    "BOOTID.UPNP.ORG": "36",
    "TYPE": "response"
}
2019-02-14 22:56:49 DEBUG (Thread-9) [UPNP_Devices] SSDP: 192.168.1.174
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.kitchen_off_if_watching_plex_pause initial state True from recorder last state <state automation.kitchen_off_if_watching_plex_pause=on; friendly_name=kitchen off if watching plex (pause), last_triggered=2019-02-14T20:49:21.766349+00:00 @ 2019-02-14T22:52:32.427637+00:00>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.174
2019-02-14 22:56:49 DEBUG (Thread-9) [UPNP_Devices] SSDP: 192.168.1.174
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.kitchen_off_if_watching_plex_pause, old_state=None, new_state=<state automation.kitchen_off_if_watching_plex_pause=off; last_triggered=2019-02-14T20:49:21.766349+00:00, friendly_name=kitchen off if watching plex (pause) @ 2019-02-14T22:56:49.067400+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Thu, 14 Feb 2019 22:56:48 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.174:7676/rcr/",
    "SERVER": "Samsung-Linux/4.1, UPnP/1.0, Samsung_UPnP_SDK/1.0",
    "ST": "urn:samsung.com:device:RemoteControlReceiver:1",
    "USN": "uuid:cfe170a0-39d8-41cc-8141-987f34dbae7a::urn:samsung.com:device:RemoteControlReceiver:1",
    "CONTENT-LENGTH": "0",
    "BOOTID.UPNP.ORG": "36",
    "TYPE": "response"
}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.kitchen_off_if_watching_plex_start_playing initial state True from recorder last state <state automation.kitchen_off_if_watching_plex_start_playing=on; friendly_name=kitchen off if watching plex (start playing), last_triggered=2019-02-14T20:47:07.785785+00:00 @ 2019-02-14T22:52:32.434336+00:00>
2019-02-14 22:56:49 DEBUG (Thread-9) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.174
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.kitchen_off_if_watching_plex_start_playing, old_state=None, new_state=<state automation.kitchen_off_if_watching_plex_start_playing=off; last_triggered=2019-02-14T20:47:07.785785+00:00, friendly_name=kitchen off if watching plex (start playing) @ 2019-02-14T22:56:49.093806+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-9) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Thu, 14 Feb 2019 22:56:49 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.174:7676/rcr/",
    "SERVER": "Samsung-Linux/4.1, UPnP/1.0, Samsung_UPnP_SDK/1.0",
    "ST": "urn:samsung.com:device:RemoteControlReceiver:1",
    "USN": "uuid:cfe170a0-39d8-41cc-8141-987f34dbae7a::urn:samsung.com:device:RemoteControlReceiver:1",
    "CONTENT-LENGTH": "0",
    "BOOTID.UPNP.ORG": "36",
    "TYPE": "response"
}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.my_morning_routine initial state True from recorder last state <state automation.my_morning_routine=on; friendly_name=My morning routine, last_triggered=2019-01-19T06:30:00.096122+00:00 @ 2019-02-14T22:52:32.439828+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.my_morning_routine, old_state=None, new_state=<state automation.my_morning_routine=off; last_triggered=2019-01-19T06:30:00.096122+00:00, friendly_name=My morning routine @ 2019-02-14T22:56:49.113800+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.christmas_automations_lovelace initial state True from recorder last state <state automation.christmas_automations_lovelace=on; friendly_name=christmas automations lovelace, hidden=True, last_triggered=None @ 2019-02-14T22:52:32.446920+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.christmas_automations_lovelace, old_state=None, new_state=<state automation.christmas_automations_lovelace=off; last_triggered=None, friendly_name=christmas automations lovelace, hidden=True @ 2019-02-14T22:56:49.127089+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.auto_christmas_lights_on_when_home initial state False from config initial_state
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.auto_christmas_lights_on_when_home, old_state=None, new_state=<state automation.auto_christmas_lights_on_when_home=off; last_triggered=None, friendly_name=auto christmas lights on when home @ 2019-02-14T22:56:49.142224+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.not_home_christams_lights_off initial state False from recorder last state <state automation.not_home_christams_lights_off=off; friendly_name=Not Home Christams Lights off, last_triggered=2018-12-31T15:13:39.205519+00:00 @ 2019-02-14T22:52:10.820606+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.not_home_christams_lights_off, old_state=None, new_state=<state automation.not_home_christams_lights_off=off; last_triggered=2018-12-31T15:13:39.205519+00:00, friendly_name=Not Home Christams Lights off @ 2019-02-14T22:56:49.155339+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.christmas_lights_wifi_bluetooth_trigger initial state True from recorder last state <state automation.christmas_lights_wifi_bluetooth_trigger=on; friendly_name=Christmas lights wifi/bluetooth trigger, hidden=True, last_triggered=None @ 2019-02-14T22:52:32.451982+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.christmas_lights_wifi_bluetooth_trigger, old_state=None, new_state=<state automation.christmas_lights_wifi_bluetooth_trigger=off; last_triggered=None, friendly_name=Christmas lights wifi/bluetooth trigger, hidden=True @ 2019-02-14T22:56:49.168590+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.christmas_group_automations_reset initial state True from recorder last state <state automation.christmas_group_automations_reset=on; friendly_name=Christmas group automations reset, hidden=True, last_triggered=2019-01-01T15:00:00.146675+00:00 @ 2019-02-14T22:52:32.456549+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.christmas_group_automations_reset, old_state=None, new_state=<state automation.christmas_group_automations_reset=off; last_triggered=2019-01-01T15:00:00.146675+00:00, friendly_name=Christmas group automations reset, hidden=True @ 2019-02-14T22:56:49.181876+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.harmony initial state True from recorder last state <state automation.harmony=on; friendly_name=Harmony, hidden=True, last_triggered=2019-02-06T16:55:35.350394+00:00 @ 2019-02-14T22:52:32.461407+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.harmony, old_state=None, new_state=<state automation.harmony=off; last_triggered=2019-02-06T16:55:35.350394+00:00, friendly_name=Harmony, hidden=True @ 2019-02-14T22:56:49.195147+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.harmony_off initial state True from recorder last state <state automation.harmony_off=on; friendly_name=Harmony Off, hidden=True, last_triggered=2019-02-06T16:55:38.961975+00:00 @ 2019-02-14T22:52:32.222340+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.harmony_off, old_state=None, new_state=<state automation.harmony_off=off; last_triggered=2019-02-06T16:55:38.961975+00:00, friendly_name=Harmony Off, hidden=True @ 2019-02-14T22:56:49.208510+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.shield_netflix initial state True from recorder last state <state automation.shield_netflix=on; friendly_name=Shield Netflix, hidden=True, last_triggered=2019-02-14T19:42:58.878724+00:00 @ 2019-02-14T22:52:32.226579+00:00>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.142
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shield_netflix, old_state=None, new_state=<state automation.shield_netflix=off; last_triggered=2019-02-14T19:42:58.878724+00:00, friendly_name=Shield Netflix, hidden=True @ 2019-02-14T22:56:49.222951+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "EXT": "",
    "LOCATION": "http://192.168.1.142:52323/dmr.xml",
    "SERVER": "Linux/3.10 UPnP/1.0 Sony-HTS/2.0",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:00000000-0000-1010-8000-045d4b2b6f3d::urn:schemas-upnp-org:device:MediaRenderer:1",
    "DATE": "Thu, 14 Feb 2019 22:56:49 GMT",
    "X-AV-PHYSICAL-UNIT-INFO": "pa=\"HT-CT800\";",
    "X-AV-SERVER-INFO": "av=5.0; cn=\"Sony Corporation\"; mn=\"HT-CT800\"; mv=\"2.0\";",
    "TYPE": "response"
}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.shield_plex initial state True from recorder last state <state automation.shield_plex=on; friendly_name=Shield Plex, hidden=True, last_triggered=2019-02-14T19:43:22.245152+00:00 @ 2019-02-14T22:52:32.237829+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shield_plex, old_state=None, new_state=<state automation.shield_plex=off; last_triggered=2019-02-14T19:43:22.245152+00:00, friendly_name=Shield Plex, hidden=True @ 2019-02-14T22:56:49.243237+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-10) [UPNP_Devices] SSDP: 192.168.1.142
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.shield_youtube initial state True from recorder last state <state automation.shield_youtube=on; friendly_name=Shield Youtube, hidden=True, last_triggered=2019-02-14T17:04:02.256294+00:00 @ 2019-02-14T22:52:32.241996+00:00>
2019-02-14 22:56:49 DEBUG (Thread-10) [UPNP_Devices] SSDP: 192.168.1.142
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.shield_youtube, old_state=None, new_state=<state automation.shield_youtube=off; last_triggered=2019-02-14T17:04:02.256294+00:00, friendly_name=Shield Youtube, hidden=True @ 2019-02-14T22:56:49.261913+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-10) [UPNP_Devices] SSDP: 192.168.1.142
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.night_time_headphones initial state True from recorder last state <state automation.night_time_headphones=on; friendly_name=Night time Headphones, hidden=True, last_triggered=2019-02-03T02:42:27.757594+00:00 @ 2019-02-14T22:52:32.253008+00:00>
2019-02-14 22:56:49 DEBUG (Thread-10) [UPNP_Devices] SSDP: 192.168.1.142
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.night_time_headphones, old_state=None, new_state=<state automation.night_time_headphones=off; last_triggered=2019-02-03T02:42:27.757594+00:00, friendly_name=Night time Headphones, hidden=True @ 2019-02-14T22:56:49.282390+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-10) [UPNP_Devices] SSDP: 192.168.1.142
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.movement_front initial state True from recorder last state <state automation.movement_front=on; friendly_name=movement_front, last_triggered=None @ 2019-02-14T22:52:32.263330+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.movement_front, old_state=None, new_state=<state automation.movement_front=off; last_triggered=None, friendly_name=movement_front @ 2019-02-14T22:56:49.299994+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.movement_back initial state True from recorder last state <state automation.movement_back=on; friendly_name=movement_back, last_triggered=None @ 2019-02-14T22:52:32.267554+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.movement_back, old_state=None, new_state=<state automation.movement_back=off; last_triggered=None, friendly_name=movement_back @ 2019-02-14T22:56:49.314877+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.movement_side initial state True from recorder last state <state automation.movement_side=on; friendly_name=movement_side, last_triggered=None @ 2019-02-14T22:52:32.283882+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.movement_side, old_state=None, new_state=<state automation.movement_side=off; last_triggered=None, friendly_name=movement_side @ 2019-02-14T22:56:49.328766+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.alarm_cctv_delay initial state True from recorder last state <state automation.alarm_cctv_delay=on; friendly_name=alarm_cctv_delay, last_triggered=None @ 2019-02-14T22:52:32.287770+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.alarm_cctv_delay, old_state=None, new_state=<state automation.alarm_cctv_delay=off; last_triggered=None, friendly_name=alarm_cctv_delay @ 2019-02-14T22:56:49.341484+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.alarm_part_arm_turn_off_downstairs initial state True from recorder last state <state automation.alarm_part_arm_turn_off_downstairs=on; friendly_name=alarm part arm turn off downstairs, last_triggered=2019-02-14T22:19:46.714552+00:00 @ 2019-02-14T22:52:32.291981+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.alarm_part_arm_turn_off_downstairs, old_state=None, new_state=<state automation.alarm_part_arm_turn_off_downstairs=off; last_triggered=2019-02-14T22:19:46.714552+00:00, friendly_name=alarm part arm turn off downstairs @ 2019-02-14T22:56:49.353884+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.alarm_fully_armed_turn_off_lights_ect initial state True from recorder last state <state automation.alarm_fully_armed_turn_off_lights_ect=on; friendly_name=alarm fully armed turn off lights ect, last_triggered=2019-02-14T08:17:34.475921+00:00 @ 2019-02-14T22:52:32.296218+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.alarm_fully_armed_turn_off_lights_ect, old_state=None, new_state=<state automation.alarm_fully_armed_turn_off_lights_ect=off; last_triggered=2019-02-14T08:17:34.475921+00:00, friendly_name=alarm fully armed turn off lights ect @ 2019-02-14T22:56:49.366333+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.home_alarm_off initial state True from recorder last state <state automation.home_alarm_off=on; friendly_name=home alarm off, last_triggered=2019-02-14T17:00:00.482610+00:00 @ 2019-02-14T22:52:32.313805+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.home_alarm_off, old_state=None, new_state=<state automation.home_alarm_off=off; last_triggered=2019-02-14T17:00:00.482610+00:00, friendly_name=home alarm off @ 2019-02-14T22:56:49.378882+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.alarm_off_notification initial state True from recorder last state <state automation.alarm_off_notification=on; friendly_name=alarm_off_notification, last_triggered=2019-02-04T13:02:36.147675+00:00 @ 2019-02-14T22:52:32.320733+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.alarm_off_notification, old_state=None, new_state=<state automation.alarm_off_notification=off; last_triggered=2019-02-04T13:02:36.147675+00:00, friendly_name=alarm_off_notification @ 2019-02-14T22:56:49.391283+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.alarm_on_notification initial state True from recorder last state <state automation.alarm_on_notification=on; friendly_name=alarm_on_notification, last_triggered=2019-02-04T15:30:14.154797+00:00 @ 2019-02-14T22:52:32.325845+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.alarm_on_notification, old_state=None, new_state=<state automation.alarm_on_notification=off; last_triggered=2019-02-04T15:30:14.154797+00:00, friendly_name=alarm_on_notification @ 2019-02-14T22:56:49.403723+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.away initial state True from recorder last state <state automation.away=on; friendly_name=Away, hidden=True, last_triggered=2019-02-14T08:17:28.398303+00:00 @ 2019-02-14T22:52:32.331976+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.away, old_state=None, new_state=<state automation.away=off; last_triggered=2019-02-14T08:17:28.398303+00:00, friendly_name=Away, hidden=True @ 2019-02-14T22:56:49.412156+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.home initial state True from recorder last state <state automation.home=on; friendly_name=Home, hidden=True, last_triggered=2019-02-14T17:00:20.555755+00:00 @ 2019-02-14T22:52:32.338463+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.home, old_state=None, new_state=<state automation.home=off; last_triggered=2019-02-14T17:00:20.555755+00:00, friendly_name=Home, hidden=True @ 2019-02-14T22:56:49.420212+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.morning_motion initial state True from recorder last state <state automation.morning_motion=on; friendly_name=morning_motion, last_triggered=2019-02-14T06:45:21.150529+00:00 @ 2019-02-14T22:52:32.344050+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.morning_motion, old_state=None, new_state=<state automation.morning_motion=off; last_triggered=2019-02-14T06:45:21.150529+00:00, friendly_name=morning_motion @ 2019-02-14T22:56:49.427178+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.morning_motion_reset initial state True from recorder last state <state automation.morning_motion_reset=on; friendly_name=morning_motion_reset, hidden=True, last_triggered=2019-02-14T09:45:00.153299+00:00 @ 2019-02-14T22:52:32.351921+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.morning_motion_reset, old_state=None, new_state=<state automation.morning_motion_reset=off; last_triggered=2019-02-14T09:45:00.153299+00:00, friendly_name=morning_motion_reset, hidden=True @ 2019-02-14T22:56:49.434251+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.group_automations_reset initial state True from recorder last state <state automation.group_automations_reset=on; friendly_name=group_automations_reset, hidden=True, last_triggered=2019-02-14T15:00:00.037091+00:00 @ 2019-02-14T22:52:32.357450+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.group_automations_reset, old_state=None, new_state=<state automation.group_automations_reset=off; last_triggered=2019-02-14T15:00:00.037091+00:00, friendly_name=group_automations_reset, hidden=True @ 2019-02-14T22:56:49.441485+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.daily_backup_at_2_am initial state True from recorder last state <state automation.daily_backup_at_2_am=on; friendly_name=Daily Backup at 2 AM, last_triggered=2019-02-14T02:00:10.030289+00:00 @ 2019-02-14T22:52:32.362591+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.daily_backup_at_2_am, old_state=None, new_state=<state automation.daily_backup_at_2_am=off; last_triggered=2019-02-14T02:00:10.030289+00:00, friendly_name=Daily Backup at 2 AM @ 2019-02-14T22:56:49.448517+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.google_backup initial state True from recorder last state <state automation.google_backup=on; friendly_name=Google Backup, last_triggered=2019-02-14T03:00:10.024355+00:00 @ 2019-02-14T22:52:32.368554+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.google_backup, old_state=None, new_state=<state automation.google_backup=off; last_triggered=2019-02-14T03:00:10.024355+00:00, friendly_name=Google Backup @ 2019-02-14T22:56:49.455608+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.home_recheck initial state True from recorder last state <state automation.home_recheck=on; friendly_name=Home Recheck, last_triggered=2019-02-14T13:29:06.181283+00:00 @ 2019-02-14T22:52:32.378558+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.home_recheck, old_state=None, new_state=<state automation.home_recheck=off; last_triggered=2019-02-14T13:29:06.181283+00:00, friendly_name=Home Recheck @ 2019-02-14T22:56:49.462611+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.wake_up_sleepy_head initial state True from recorder last state <state automation.wake_up_sleepy_head=on; friendly_name=wake up sleepy head, last_triggered=2019-02-07T06:50:00.074321+00:00 @ 2019-02-14T22:52:32.386433+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.wake_up_sleepy_head, old_state=None, new_state=<state automation.wake_up_sleepy_head=off; last_triggered=2019-02-07T06:50:00.074321+00:00, friendly_name=wake up sleepy head @ 2019-02-14T22:56:49.469634+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.okay_to_get_up initial state True from recorder last state <state automation.okay_to_get_up=on; friendly_name=okay to get up, icon=mdi:human-handsup, last_triggered=2019-02-14T06:40:00.162347+00:00 @ 2019-02-14T22:52:32.393810+00:00>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.okay_to_get_up, old_state=None, new_state=<state automation.okay_to_get_up=off; last_triggered=2019-02-14T06:40:00.162347+00:00, friendly_name=okay to get up, icon=mdi:human-handsup @ 2019-02-14T22:56:49.476586+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.components.automation] Automation automation.auto_lights_on_when_home initial state False from config initial_state
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.auto_lights_on_when_home, old_state=None, new_state=<state automation.auto_lights_on_when_home=off; last_triggered=None, friendly_name=auto lights on when home @ 2019-02-14T22:56:49.483214+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.media_controls, old_state=<state group.media_controls=unknown; entity_id=('group.plex_media', 'group.harmony_control', 'group.harmony', 'group.channels', 'group.players'), order=1, view=True, friendly_name=Media Controls, icon=mdi:theater, hidden=True @ 2019-02-14T22:56:43.776334+00:00>, new_state=<state group.media_controls=off; entity_id=('group.plex_media', 'group.harmony_control', 'group.harmony', 'group.channels', 'group.players'), order=1, view=True, friendly_name=Media Controls, icon=mdi:theater, hidden=True @ 2019-02-14T22:56:49.488607+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.htpc, old_state=<state group.htpc=unknown; entity_id=('sensor.nzbget_speed', 'sensor.nzbget_article_cache', 'sensor.nzbget_download_paused', 'group.ssl', 'group.htpc_controls', 'group.plexstreams', 'group.phairmedia_server'), order=2, view=True, friendly_name=HTPC, icon=mdi:desktop-classic, hidden=True @ 2019-02-14T22:56:43.979357+00:00>, new_state=<state group.htpc=off; entity_id=('sensor.nzbget_speed', 'sensor.nzbget_article_cache', 'sensor.nzbget_download_paused', 'group.ssl', 'group.htpc_controls', 'group.plexstreams', 'group.phairmedia_server'), order=2, view=True, friendly_name=HTPC, icon=mdi:desktop-classic, hidden=True @ 2019-02-14T22:56:49.494641+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.all_scripts, old_state=None, new_state=<state group.all_scripts=off; entity_id=('script.get_david', 'script.nightlight_alexander', 'script.morningwakeup_alexander', 'script.bbcnews', 'script.bbcone', 'script.bbctwo', 'script.clean_plex', 'script.five', 'script.four', 'script.homealarm_on', 'script.lightdownstairs_off', 'script.lightdownstairs_on', 'script.manaul_backup', 'script.manaul_google_upload', 'script.wakeup_master_bedroom', 'script.morning_workout_alarm', 'script.nzbget_pause', 'script.nzbget_resume', 'script.reboot_htpc', 'script.stop_plex_streams', 'script.tv_not_home_off', 'script.tv_not_home_on', 'script.kindle_update', 'script.update_plex_cartoons', 'script.update_plex_movies', 'script.cbbc', 'script.cctv_notice', 'script.download', 'script.goodnight', 'script.homesos', 'script.house_temperature_readout', 'script.itv', 'script.kitchenspotlights', 'script.morning_radio', 'script.morninginfo', 'script.plexpause', 'script.plexplay', 'script.plex_updated', 'script.plexwatch', 'script.shieldtest', 'script.skynews', 'script.plexstop', 'script.tvvolumedown', 'script.tvvolumeup', 'script.weather'), order=39, auto=True, friendly_name=all scripts, hidden=True @ 2019-02-14T22:56:49.520398+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.automations, old_state=<state group.automations=unknown; entity_id=('automation.auto_lights_on_when_home', 'automation.okay_to_get_up', 'automation.away', 'automation.kitchen_off_if_watching_plex_pause', 'automation.kitchen_off_if_watching_plex_start_playing'), order=37, friendly_name=Automations @ 2019-02-14T22:56:45.513167+00:00>, new_state=<state group.automations=off; entity_id=('automation.auto_lights_on_when_home', 'automation.okay_to_get_up', 'automation.away', 'automation.kitchen_off_if_watching_plex_pause', 'automation.kitchen_off_if_watching_plex_start_playing'), order=37, friendly_name=Automations @ 2019-02-14T22:56:49.526474+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.christmas_automations, old_state=<state group.christmas_automations=unknown; entity_id=('automation.auto_christmas_lights_on_when_home', 'automation.not_home_christams_lights_off'), order=38, friendly_name=Christmas Automations @ 2019-02-14T22:56:45.530078+00:00>, new_state=<state group.christmas_automations=off; entity_id=('automation.auto_christmas_lights_on_when_home', 'automation.not_home_christams_lights_off'), order=38, friendly_name=Christmas Automations @ 2019-02-14T22:56:49.536445+00:00>>
2019-02-14 22:56:49 DEBUG (SyncWorker_12) [pyHS100.protocol] > (31) {"system": {"get_sysinfo": {}}}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.cctv_triggers, old_state=<state group.cctv_triggers=unknown; entity_id=('automation.movement_front', 'automation.movement_side', 'automation.movement_back'), order=36, friendly_name=CCTV triggers @ 2019-02-14T22:56:45.493072+00:00>, new_state=<state group.cctv_triggers=off; entity_id=('automation.movement_front', 'automation.movement_side', 'automation.movement_back'), order=36, friendly_name=CCTV triggers @ 2019-02-14T22:56:49.545096+00:00>>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=automation, service=trigger>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=automation, service=reload>
2019-02-14 22:56:49 DEBUG (SyncWorker_12) [pyHS100.protocol] < (561) {"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 171213 Rel.101014","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(UK)","mac":"50:C7:BF:77:C8:67","deviceId":"8006A4A97D71BB5C7E324E60A4337BC7187DA863","hwId":"522CBD4857687F1AE7D7EE9B440BF26B","fwId":"00000000000000000000000000000000","oemId":"9F26B8A5A0266993C796D0BF593B8415","alias":"Lamp","dev_name":"Wi-Fi Smart Plug","icon_hash":"","relay_state":0,"on_time":0,"active_mode":"schedule","feature":"TIM","updating":0,"rssi":-62,"led_off":0,"latitude":52.862557,"longitude":-1.433318}}}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=automation, service=toggle>
2019-02-14 22:56:49 DEBUG (SyncWorker_12) [pyHS100.protocol] > (31) {"system": {"get_sysinfo": {}}}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=automation, service=turn_on>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=automation, service=turn_off>
2019-02-14 22:56:49 DEBUG (SyncWorker_12) [pyHS100.protocol] < (561) {"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 171213 Rel.101014","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(UK)","mac":"50:C7:BF:77:C8:67","deviceId":"8006A4A97D71BB5C7E324E60A4337BC7187DA863","hwId":"522CBD4857687F1AE7D7EE9B440BF26B","fwId":"00000000000000000000000000000000","oemId":"9F26B8A5A0266993C796D0BF593B8415","alias":"Lamp","dev_name":"Wi-Fi Smart Plug","icon_hash":"","relay_state":0,"on_time":0,"active_mode":"schedule","feature":"TIM","updating":0,"rssi":-62,"led_off":0,"latitude":52.862557,"longitude":-1.433318}}}
2019-02-14 22:56:49 INFO (MainThread) [homeassistant.setup] Setup of domain automation took 3.4 seconds.
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=automation>
2019-02-14 22:56:49 INFO (MainThread) [homeassistant.components.light] Setting up light.hue
2019-02-14 22:56:49 INFO (SyncWorker_7) [homeassistant.components.device_tracker.nmap_tracker] Scanning...
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=group, service=set, service_data=object_id=all_automations, name=all automations, visible=False, entities=['automation.away', 'automation.christmas_group_automations_reset', 'automation.christmas_lights_wifi_bluetooth_trigger', 'automation.daily_backup_at_2_am', 'automation.google_backup', 'automation.harmony', 'automation.harmony_off', 'automation.home', 'automation.home_recheck', 'automation.my_morning_routine', 'automation.night_time_headphones', 'automation.not_home_christams_lights_off', 'automation.shield_netflix', 'automation.shield_plex', 'automation.shield_youtube', 'automation.alarm_fully_armed_turn_off_lights_ect', 'automation.alarm_part_arm_turn_off_downstairs', 'automation.alarm_cctv_delay', 'automation.alarm_off_notification', 'automation.alarm_on_notification', 'automation.auto_christmas_lights_on_when_home', 'automation.auto_lights_on_coming_home_motion', 'automation.auto_lights_on_coming_home_wifi_bluetooth_trigger', 'automation.auto_lights_on_when_home', 'automation.christmas_automations_lovelace', 'automation.group_automations_reset', 'automation.home_alarm_off', 'automation.kitchen_off_if_watching_plex_pause', 'automation.kitchen_off_if_watching_plex_start_playing', 'automation.lights_off_cloud_coverage', 'automation.lights_off_if_the_sun_is_up', 'automation.morning_light_if_dark', 'automation.morning_motion', 'automation.morning_motion_reset', 'automation.movement_back', 'automation.movement_front', 'automation.movement_side', 'automation.okay_to_get_up', 'automation.wake_up_sleepy_head']>
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.living_room_lamp, old_state=None, new_state=<state switch.living_room_lamp=off; friendly_name=Living_room_lamp, icon=mdi:floor-lamp @ 2019-02-14T22:56:49.823035+00:00>>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.1
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=turn_on>
2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] {
    "HOST": "239.255.255.250:1900",
    "EXT": "",
    "CACHE-CONTROL": "max-age=100",
    "LOCATION": "http://192.168.1.1:80/description.xml",
    "SERVER": "Linux/3.14.0 UPnP/1.0 IpBridge/1.29.0",
    "HUE-BRIDGEID": "001788FFFE7F03A9",
    "ST": "upnp:rootdevice",
    "USN": "uuid:2f402f80-da50-11e1-9b23-0017887f03a9::upnp:rootdevice",
    "TYPE": "response"
}
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=turn_off>
2019-02-14 22:56:49 DEBUG (Thread-11) [UPNP_Devices] SSDP: 192.168.1.1
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.1
2019-02-14 22:56:49 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=toggle>
2019-02-14 22:56:49 DEBUG (Thread-11) [UPNP_Devices] SSDP: 192.168.1.1
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:49 DEBUG (Thread-5) [UPNP_Devices] {
    "HOST": "239.255.255.250:1900",
    "EXT": "",
    "CACHE-CONTROL": "max-age=100",
    "LOCATION": "http://192.168.1.1:80/description.xml",
    "SERVER": "Linux/3.14.0 UPnP/1.0 IpBridge/1.29.0",
    "HUE-BRIDGEID": "001788FFFE7F03A9",
    "ST": "uuid:2f402f80-da50-11e1-9b23-0017887f03a9",
    "USN": "uuid:2f402f80-da50-11e1-9b23-0017887f03a9",
    "TYPE": "response"
}
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=volume_up>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=volume_down>
2019-02-14 22:56:50 DEBUG (Thread-11) [UPNP_Devices] SSDP: 192.168.1.1
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:50 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.1
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_play_pause>
2019-02-14 22:56:50 DEBUG (Thread-11) [UPNP_Devices] SSDP: 192.168.1.1
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:50 DEBUG (Thread-5) [UPNP_Devices] {
    "HOST": "239.255.255.250:1900",
    "EXT": "",
    "CACHE-CONTROL": "max-age=100",
    "LOCATION": "http://192.168.1.1:80/description.xml",
    "SERVER": "Linux/3.14.0 UPnP/1.0 IpBridge/1.29.0",
    "HUE-BRIDGEID": "001788FFFE7F03A9",
    "ST": "urn:schemas-upnp-org:device:basic:1",
    "USN": "uuid:2f402f80-da50-11e1-9b23-0017887f03a9",
    "TYPE": "response"
}
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_play>
2019-02-14 22:56:50 DEBUG (Thread-11) [UPNP_Devices] SSDP: 192.168.1.1
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_pause>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_stop>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_next_track>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_previous_track>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=clear_playlist>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=volume_set>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=volume_mute>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=media_seek>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=select_source>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=select_sound_mode>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=play_media>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=media_player, service=shuffle_set>
2019-02-14 22:56:50 INFO (MainThread) [homeassistant.setup] Setup of domain media_player took 8.9 seconds.
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=media_player>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.all_automations, old_state=None, new_state=<state group.all_automations=off; entity_id=('automation.away', 'automation.christmas_group_automations_reset', 'automation.christmas_lights_wifi_bluetooth_trigger', 'automation.daily_backup_at_2_am', 'automation.google_backup', 'automation.harmony', 'automation.harmony_off', 'automation.home', 'automation.home_recheck', 'automation.my_morning_routine', 'automation.night_time_headphones', 'automation.not_home_christams_lights_off', 'automation.shield_netflix', 'automation.shield_plex', 'automation.shield_youtube', 'automation.alarm_fully_armed_turn_off_lights_ect', 'automation.alarm_part_arm_turn_off_downstairs', 'automation.alarm_cctv_delay', 'automation.alarm_off_notification', 'automation.alarm_on_notification', 'automation.auto_christmas_lights_on_when_home', 'automation.auto_lights_on_coming_home_motion', 'automation.auto_lights_on_coming_home_wifi_bluetooth_trigger', 'automation.auto_lights_on_when_home', 'automation.christmas_automations_lovelace', 'automation.group_automations_reset', 'automation.home_alarm_off', 'automation.kitchen_off_if_watching_plex_pause', 'automation.kitchen_off_if_watching_plex_start_playing', 'automation.lights_off_cloud_coverage', 'automation.lights_off_if_the_sun_is_up', 'automation.morning_light_if_dark', 'automation.morning_motion', 'automation.morning_motion_reset', 'automation.movement_back', 'automation.movement_front', 'automation.movement_side', 'automation.okay_to_get_up', 'automation.wake_up_sleepy_head'), order=40, auto=True, friendly_name=all automations, hidden=True @ 2019-02-14T22:56:50.402974+00:00>>
2019-02-14 22:56:50 INFO (MainThread) [homeassistant.loader] Loaded media_player.cast from homeassistant.components.media_player.cast
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.lights, old_state=<state group.lights=unknown; entity_id=('switch.living_room_lamp',), order=5, friendly_name=lights @ 2019-02-14T22:56:44.702617+00:00>, new_state=<state group.lights=off; entity_id=('switch.living_room_lamp',), order=5, friendly_name=lights @ 2019-02-14T22:56:50.583914+00:00>>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.downstairs_lights, old_state=<state group.downstairs_lights=unknown; entity_id=('light.hall', 'switch.living_room_lamp', 'light.living_room', 'light.dinning_room', 'light.kitchen', 'light.utility'), order=26, friendly_name=Downstairs lights @ 2019-02-14T22:56:45.287677+00:00>, new_state=<state group.downstairs_lights=off; entity_id=('light.hall', 'switch.living_room_lamp', 'light.living_room', 'light.dinning_room', 'light.kitchen', 'light.utility'), order=26, friendly_name=Downstairs lights @ 2019-02-14T22:56:50.610580+00:00>>
2019-02-14 22:56:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=group, service=set, service_data=object_id=all_switches, name=all switches, visible=False, entities=['switch.living_room_lamp']>
`

I just moved samsungtv.py from my custom_components to the components directory and reboot HA. Still no PIN code displayed on the TV.

I have to go to work, so I'll check up on this later.

FWIW I'm running in docker (as many are) so /components/media_player is effectively immutable and we have to rely on /custom_component.

Guys....it is perfectly fine to use custom components. The warning is to make sure that folks don't blame HA if things break.

Ah ok, I thought that might be the case but kdschlosser seemed quite insistent :)

Well the component does nothing for me then - I get a warning about "You are using a custom component for media_player.samsungtv"...so it's being picked up by HA. It also is creating a samsung_tv folder. But nothing else in the logs, and no notification in the UI of any kind. Will try and debug tomorrow.

Ah ok, I thought that might be the case but kdschlosser seemed quite insistent :)

Well the component does nothing for me then - I get a warning about "You are using a custom component for media_player.samsungtv"...so it's being picked up by HA. It also is creating a samsung_tv folder. But nothing else in the logs, and no notification in the UI of any kind. Will try and debug tomorrow.

Add this to your configuration.yaml file (at the bottom)

logger:
    default: debug  <==== THIS HAS TO STAY AS DEBUG
    logs:
      custom_components.media_player.samsungtv: debug
      samsungctl: debug

@phairplay

what is the model number of your TV?

@timdonovanuk

I need you to add this to the bottom of your configuration.yaml file

logger:
    default: debug
    logs:
      custom_components.media_player.samsungtv: debug
      samsungctl: debug

then run home assistant. it is going to output a bunch of stuff to the screen. let it run for 2 minutes. then copy and paste the output into a text file and attach it to a post in here. I also need to know what the whole model number of your TV is please.

So those if you that are having an issue with thee detection of the TV not working. follow the instructions above.

because of the number of years we are dealing with along with the number of different models. I do not know what TV's support what UPNP service classes. the logging is going to tell me what the TV responds to and what it doesn't. I can then fine tune the detection to include your TV.

i updated the code in the first post. give it a try if your TV was not getting detected.

Seeing with the latest code

Log Details (ERROR)
Thu Feb 14 2019 20:36:08 GMT-0500 (Eastern Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 257, in _async_add_entity
    if entity.unique_id is not None:
  File "/config/custom_components/media_player/samsungtv.py", line 519, in unique_id
    return '{' + self._config.uuid + '}'
TypeError: must be str, not NoneType

delete all file in your samsung_tv config path. and try it again. I forgot to mention to do that.

@kdschlosser
UE55MU6120

@phairplay

I updated the code. and I did add the upnp classes to the discovery correctly for your TV (lucky guess).

You can give the new code in the first post a go. just make sure you delete all of the files in the samsung_tv config path before running hass.

I am in the process of changing the library to not be dependant on the IP address of the TV. I am putting more work into the UPNP end of things. this is going to be the way to go about detecting the TV's state and also locating new TV's added to your network.

so basically having to set your TV to a static IP will not have to be done anymore.
and if you go out and buy a new TV and connect it to your network. hass will almost instantly notify you of the new TV and if you want to add it. no restarts needed!!

those changes will be made in the next 2 days or so. the reasoning for this is instead of trying to constantly open a socket every second or so (resource intensive) i am going to rely on UPNP discovery packets. the UPNP will keep on broadcasting keeping a single socket open and that single socket will handle all of the TV's on the network. this will by far use less resources it will be a lot more apparent if there are multiple TV's being handled

Just tried the latest version. Still no PIN on my TV. My TV is model UA60H6400. If you need me to provide any info, let me know exactly what and how.

okay so it detects my TV and i see the config notification in HA, a notification appears on the tv.

yet HA see my tv as off and doesn't change state (even when pressed)

I'll post the logs if required later (off to work)

@kdschlosser
Thank you very much for the great job you are doing. I am looking forward to having my TV integrated in HA.

I have a Samsung UE48J6250 (encrypted websocket I think). I have tried the code on the first post on hassio 0.87.1 as a custom_component.

I am getting the configuration notification which seems to discover the TV correctly and then I am requested for the PIN, but I do not get the PIN on the TV. No file gets created into the samsung_tv folder either.

Here are the relevant parts from the log:

...
2019-02-15 08:57:55 INFO (MainThread) [homeassistant.loader] Loaded media_player.samsungtv from custom_components.media_player.samsungtv
2019-02-15 08:57:55 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.samsungtv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

...

2019-02-15 08:57:59 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.samsungtv

...

2019-02-15 08:58:02 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-6) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-5) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-7) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:02 DEBUG (Thread-4) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0

...

2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:03 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:9197/dmr",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:9aef54de-38fb-40a2-af66-7239c2579cc4::urn:schemas-upnp-org:device:MediaRenderer:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-15 08:58:04 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:04 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:03 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:7678/nservice/",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:dial-multiscreen-org:device:dialreceiver:1",
    "USN": "uuid:e444aca4-e0e0-485c-ba24-a36be4f3abc9::urn:dial-multiscreen-org:device:dialreceiver:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-15 08:58:04 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:04 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:03 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:7677/MainTVServer2/",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:samsung.com:device:MainTVServer2:1",
    "USN": "uuid:c1fd12b2-d954-4dba-9e92-a697e1558fb4::urn:samsung.com:device:MainTVServer2:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:04 DEBUG (Thread-8) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:04 DEBUG (Thread-5) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:03 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:7676/rcr/",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:samsung.com:device:RemoteControlReceiver:1",
    "USN": "uuid:f04aff57-6d4c-44f4-b4f9-b3197955e8c3::urn:samsung.com:device:RemoteControlReceiver:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}

...

2019-02-15 08:58:09 DEBUG (Thread-3) [custom_components.media_player.samsungtv] name = Samsung TV Connector [homeassistant]
description = homeassistant
host = 192.168.1.169
port = 8080
id = 7bd6695-e533-43ea-89f5-13ff0fdd749
method = encrypted
timeout = 0
token = None
upnp_locations = http://192.168.1.169:9197/dmr, http://192.168.1.169:7678/nservice/, http://192.168.1.169:7676/rcr/, http://192.168.1.169:7677/MainTVServer2/
paired = False
mac = 14:BB:6E:86:CA:F3
model = UE48J6200
app_id = 12345
uuid = 9aef54de-38fb-40a2-af66-7239c2579cc4
display_name = None

2019-02-15 08:58:09 INFO (Thread-3) [homeassistant.loader] Loaded configurator from homeassistant.components.configurator
2019-02-15 08:58:09 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=configurator, service=configure>
2019-02-15 08:58:09 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=configurator.ue48j6200, old_state=None, new_state=<state configurator.ue48j6200=configure; configure_id=1877922384-1, fields=[{'id': 'display_name', 'name': 'Name: UE48J6200', 'type': ''}, {'id': 'description', 'name': 'Description: homeassistant', 'type': ''}, {'id': 'mac', 'name': 'MAC Address : 14:BB:6E:86:CA:F3', 'type': ''}], friendly_name=UE48J6200, entity_picture=None, description=New TV discovered, would you like to add the TV?

![Description image](/static/images/smart-tv.png), submit_caption=Accept @ 2019-02-15T08:58:09.854689+01:00>>
...
2019-02-15 08:58:33 DEBUG (SyncWorker_11) [homeassistant.util.json] JSON file not found: /config/custom_components/media_player/.translations/samsungtv.en.json
...
2019-02-15 08:58:35 INFO (MainThread) [homeassistant.components.discovery] Found new service: samsung_tv {'host': '192.168.1.169', 'port': 7676, 'ssdp_description': 'http://192.168.1.169:7676/rcr/', 'name': 'Samsung', 'model_name': 'UE48J6200', 'model_number': '1.0', 'serial': '20090804RCR', 'manufacturer': 'Samsung Electronics', 'udn': 'uuid:f04aff57-6d4c-44f4-b4f9-b3197955e8c3', 'upnp_device_type': 'urn:samsung.com:device:RemoteControlReceiver:1'}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.media_player, platform=samsungtv, discovered=host=192.168.1.169, port=7676, ssdp_description=http://192.168.1.169:7676/rcr/, name=Samsung, model_name=UE48J6200, model_number=1.0, serial=20090804RCR, manufacturer=Samsung Electronics, udn=uuid:f04aff57-6d4c-44f4-b4f9-b3197955e8c3, upnp_device_type=urn:samsung.com:device:RemoteControlReceiver:1>
2019-02-15 08:58:35 INFO (MainThread) [homeassistant.components.discovery] Found new service: kodi {'host': '192.168.1.166', 'port': 8080, 'hostname': 'guestroom-kodi.local.', 'properties': {}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.media_player, platform=kodi, discovered=host=192.168.1.166, port=8080, hostname=guestroom-kodi.local., properties=>
2019-02-15 08:58:35 INFO (MainThread) [homeassistant.components.discovery] Unknown service discovered: dlna_dmr {'host': '192.168.1.169', 'port': 9197, 'ssdp_description': 'http://192.168.1.169:9197/dmr', 'name': '[TV] Samsung', 'model_name': 'UE48J6200', 'model_number': 'AllShare1.0', 'serial': '20150119DMR', 'manufacturer': 'Samsung Electronics', 'udn': 'uuid:9aef54de-38fb-40a2-af66-7239c2579cc4', 'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1'}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations), notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=dismiss, service_data=notification_id=config_entry_discovery>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 467235, tzinfo=<UTC>), 'context': {'id': '9ca6f50d358e403cb9e4e04def86144e', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 471130, tzinfo=<UTC>), 'context': {'id': 'd356b2182de7435abd45e9f5ebbd2436', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 474668, tzinfo=<UTC>), 'context': {'id': '66af468240b14b6ab0b63f924b8ff580', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 477896, tzinfo=<UTC>), 'context': {'id': 'f1eb4877bbe94d8fb11945fd4d8692f1', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 481258, tzinfo=<UTC>), 'context': {'id': 'e97cd25f11114772a78b9948b906df7c', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 484390, tzinfo=<UTC>), 'context': {'id': '2338854b77874f9da528556fdd3fda54', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'config_entry_discovered', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 487756, tzinfo=<UTC>), 'context': {'id': '8068340c61514cab9baf1bc8d98a245b', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'platform_discovered', 'data': {'service': 'load_platform.media_player', 'platform': 'samsungtv', 'discovered': {'host': '192.168.1.169', 'port': 7676, 'ssdp_description': 'http://192.168.1.169:7676/rcr/', 'name': 'Samsung', 'model_name': 'UE48J6200', 'model_number': '1.0', 'serial': '20090804RCR', 'manufacturer': 'Samsung Electronics', 'udn': 'uuid:f04aff57-6d4c-44f4-b4f9-b3197955e8c3', 'upnp_device_type': 'urn:samsung.com:device:RemoteControlReceiver:1'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 496088, tzinfo=<UTC>), 'context': {'id': '685dab56491f4364ae5b2b8411770126', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'platform_discovered', 'data': {'service': 'load_platform.media_player', 'platform': 'kodi', 'discovered': {'host': '192.168.1.166', 'port': 8080, 'hostname': 'guestroom-kodi.local.', 'properties': {}}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 502986, tzinfo=<UTC>), 'context': {'id': '37e49921594b42f4a295d83265cab791', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.667794+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.667794+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.690644+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.690644+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.719091+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.719091+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.741934+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.741934+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.766140+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.766140+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.803507+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.803507+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=None, new_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.834898+01:00>>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.config_entry_discovery, old_state=<state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.834898+01:00>, new_state=None>
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event persistent_notifications_updated[L]>
2019-02-15 08:58:35 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.samsungtv
2019-02-15 08:58:35 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.kodi
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 520653, tzinfo=<UTC>), 'context': {'id': '39993e0ec56341c6a0aeaaedf96237d5', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 524231, tzinfo=<UTC>), 'context': {'id': '008d12ce94a145aea82e1c7839360957', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 536297, tzinfo=<UTC>), 'context': {'id': 'e0ea78acdbee40cbb6c2670decb7a7d7', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 540024, tzinfo=<UTC>), 'context': {'id': 'cf7ce0207f024446a11d1eba3044630f', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 553524, tzinfo=<UTC>), 'context': {'id': '3ab7b7e446f14c6d9878414b2034d9f7', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 557821, tzinfo=<UTC>), 'context': {'id': '73a2c911e4f348a9b11f92dc32b243a4', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 572000, tzinfo=<UTC>), 'context': {'id': '7e1dfeec6f924a76a2096f5bc2f08754', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 576958, tzinfo=<UTC>), 'context': {'id': 'b79c0d929f284a1087ad5a150477efe7', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 590645, tzinfo=<UTC>), 'context': {'id': '44efd3fa792f49fe8b400a50cd7c6742', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 595159, tzinfo=<UTC>), 'context': {'id': 'f27317b6e6744d6da90368c35f1fad6e', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 609643, tzinfo=<UTC>), 'context': {'id': 'f72b73aa70b54b09b4fac1557c3a7a64', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 613740, tzinfo=<UTC>), 'context': {'id': '4ed2cde4e777499fb10f8e7939e0062d', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'create', 'service_data': {'title': 'New devices discovered', 'message': 'We have discovered new devices on your network. [Check it out](/config/integrations)', 'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 627603, tzinfo=<UTC>), 'context': {'id': 'a12707eb075c49a28d04065b8cccc88e', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'persistent_notification', 'service': 'dismiss', 'service_data': {'notification_id': 'config_entry_discovery'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 631125, tzinfo=<UTC>), 'context': {'id': 'a414aec068564b8282e6c4e1b6af31dd', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.667794+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 667988, tzinfo=<UTC>), 'context': {'id': '90be7a1218144c4b92562be3e6458ca4', 'user_id': None}}}
2019-02-15 08:58:35 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 675005, tzinfo=<UTC>), 'context': {'id': '9f0cdad14dd44d4e9ed22f3eddb5641a', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.667794+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 678660, tzinfo=<UTC>), 'context': {'id': '6ea0074a3d414bd187d7b503d8e11d5a', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-18) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 686415, tzinfo=<UTC>), 'context': {'id': 'e6744e5d5b574ed68165437d545fc27e', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-18) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-21) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-20) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-18) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-20) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.690644+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 690773, tzinfo=<UTC>), 'context': {'id': '23cf74b614c9494a852474b70d36cd1f', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-21) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-18) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-20) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 698367, tzinfo=<UTC>), 'context': {'id': '8ed2da73e7ce4e87b15b4fe40a2e972b', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-21) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-18) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-20) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.690644+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 702149, tzinfo=<UTC>), 'context': {'id': '0df8b4af37934a4fafdbf3b6d112c18e', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-21) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-20) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 715137, tzinfo=<UTC>), 'context': {'id': '985eb6b48e904eaabc2e5fdb222f554a', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-21) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: 239.255.255.250
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.719091+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 719216, tzinfo=<UTC>), 'context': {'id': 'e3f416c9a8574d00b92f580e5d183394', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 727093, tzinfo=<UTC>), 'context': {'id': '3c4c112f7ba4468589ccce0d8addb1d9', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.719091+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 730542, tzinfo=<UTC>), 'context': {'id': '263b7d66f2ad492ab4ab81b2836d5c5e', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 738001, tzinfo=<UTC>), 'context': {'id': 'decb4db729844cda80fdca72eec6507f', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.741934+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 742062, tzinfo=<UTC>), 'context': {'id': '2b4203bea5a044c6b7ca1b299b9d2332', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 750279, tzinfo=<UTC>), 'context': {'id': 'a4e9bb15ec144005b4ef1e258ba2c945', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:35 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:9197/dmr",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:schemas-upnp-org:device:MediaRenderer:1",
    "USN": "uuid:9aef54de-38fb-40a2-af66-7239c2579cc4::urn:schemas-upnp-org:device:MediaRenderer:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.741934+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 754261, tzinfo=<UTC>), 'context': {'id': 'afc397e72d304906af2410b8fe0a0522', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 761736, tzinfo=<UTC>), 'context': {'id': 'a190a90638b14c27a9498c5693445e3d', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.766140+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 766280, tzinfo=<UTC>), 'context': {'id': '4b84637997304892b5322484d8ad3665', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-22) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:schemas-upnp-org:device:MediaRenderer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 779449, tzinfo=<UTC>), 'context': {'id': 'c9e9996594d847fca3484f96dd28e626', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-22) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:IPControlServer:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.766140+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 787106, tzinfo=<UTC>), 'context': {'id': 'bf77bcc3ba0f46cea9c41ce86b9e80aa', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-22) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:dial-multiscreen-org:device:dialreceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 795581, tzinfo=<UTC>), 'context': {'id': '873c0b4a409644ec8629b85073c742f9', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-22) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:MainTVServer2:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.803507+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 803676, tzinfo=<UTC>), 'context': {'id': '266b201256c942efa5c22c3cb62e5506', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-22) [UPNP_Devices] SSDP: 192.168.1.169
M-SEARCH * HTTP/1.1
ST: urn:samsung.com:device:RemoteControlReceiver:1
MAN: "ssdp:discover"
HOST: 239.255.255.250:1900
MX: 1
Content-Length: 0


2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 814134, tzinfo=<UTC>), 'context': {'id': '7d20e88d7de94201b984cb44206ec04b', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.803507+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 818361, tzinfo=<UTC>), 'context': {'id': '01784d038fef4e958a5b7beaaa909fcf', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 827000, tzinfo=<UTC>), 'context': {'id': 'e06eff2ab99a4260a1000be51e583438', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.834898+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 835165, tzinfo=<UTC>), 'context': {'id': '37ea3a8a37264d69ba39a4503556c6d9', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 842663, tzinfo=<UTC>), 'context': {'id': '9e638696f8bd4ac0b9d50f87731f3292', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.834898+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 846925, tzinfo=<UTC>), 'context': {'id': 'dc0ebd47d3e84397ac9411f6dd095244', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'persistent_notifications_updated', 'data': {}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 854803, tzinfo=<UTC>), 'context': {'id': 'b6d98bd239814bc184efde6db3077d8b', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.667794+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 667988, tzinfo=<UTC>), 'context': {'id': '90be7a1218144c4b92562be3e6458ca4', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.667794+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 678660, tzinfo=<UTC>), 'context': {'id': '6ea0074a3d414bd187d7b503d8e11d5a', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.690644+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 690773, tzinfo=<UTC>), 'context': {'id': '23cf74b614c9494a852474b70d36cd1f', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.690644+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 702149, tzinfo=<UTC>), 'context': {'id': '0df8b4af37934a4fafdbf3b6d112c18e', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.719091+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 719216, tzinfo=<UTC>), 'context': {'id': 'e3f416c9a8574d00b92f580e5d183394', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.719091+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 730542, tzinfo=<UTC>), 'context': {'id': '263b7d66f2ad492ab4ab81b2836d5c5e', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.741934+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 742062, tzinfo=<UTC>), 'context': {'id': '2b4203bea5a044c6b7ca1b299b9d2332', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.741934+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 754261, tzinfo=<UTC>), 'context': {'id': 'afc397e72d304906af2410b8fe0a0522', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.766140+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 766280, tzinfo=<UTC>), 'context': {'id': '4b84637997304892b5322484d8ad3665', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.766140+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 787106, tzinfo=<UTC>), 'context': {'id': 'bf77bcc3ba0f46cea9c41ce86b9e80aa', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.803507+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 803676, tzinfo=<UTC>), 'context': {'id': '266b201256c942efa5c22c3cb62e5506', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.803507+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 818361, tzinfo=<UTC>), 'context': {'id': '01784d038fef4e958a5b7beaaa909fcf', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': None, 'new_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.834898+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 835165, tzinfo=<UTC>), 'context': {'id': '37ea3a8a37264d69ba39a4503556c6d9', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'persistent_notification.config_entry_discovery', 'old_state': <state persistent_notification.config_entry_discovery=notifying; title=New devices discovered, message=We have discovered new devices on your network. [Check it out](/config/integrations) @ 2019-02-15T08:58:35.834898+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 58, 35, 846925, tzinfo=<UTC>), 'context': {'id': 'dc0ebd47d3e84397ac9411f6dd095244', 'user_id': None}}}
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:35 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:7678/nservice/",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:dial-multiscreen-org:device:dialreceiver:1",
    "USN": "uuid:e444aca4-e0e0-485c-ba24-a36be4f3abc9::urn:dial-multiscreen-org:device:dialreceiver:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] SSDP: inbound packet for IP 192.168.1.169
2019-02-15 08:58:36 DEBUG (Thread-19) [UPNP_Devices] {
    "CACHE-CONTROL": "max-age=1800",
    "DATE": "Fri, 15 Feb 2019 07:58:35 GMT",
    "EXT": "",
    "LOCATION": "http://192.168.1.169:7676/rcr/",
    "SERVER": "SHP, UPnP/1.0, Samsung UPnP SDK/1.0",
    "ST": "urn:samsung.com:device:RemoteControlReceiver:1",
    "USN": "uuid:f04aff57-6d4c-44f4-b4f9-b3197955e8c3::urn:samsung.com:device:RemoteControlReceiver:1",
    "CONTENT-LENGTH": "0",
    "TYPE": "response"
}

...

2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Received {'type': 'call_service', 'domain': 'configurator', 'service': 'configure', 'service_data': {'configure_id': '1877922384-1', 'fields': {'description': 'LivingTV', 'pin': '', 'display_name': 'UE48J6250'}}, 'id': 22}
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=configurator, service=configure, service_data=configure_id=1877922384-1, fields=description=LivingTV, pin=, display_name=UE48J6250>
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'configurator', 'service': 'configure', 'service_data': {'configure_id': '1877922384-1', 'fields': {'description': 'LivingTV', 'pin': '', 'display_name': 'UE48J6250'}}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 22, 167878, tzinfo=<UTC>), 'context': {'id': 'f7f28696297745ccb309282e9c3ec103', 'user_id': None}}}
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=configurator.ue48j6200, old_state=<state configurator.ue48j6200=configure; configure_id=1877922384-1, fields=[{'id': 'display_name', 'name': 'Name: UE48J6200', 'type': ''}, {'id': 'description', 'name': 'Description: homeassistant', 'type': ''}, {'id': 'mac', 'name': 'MAC Address : 14:BB:6E:86:CA:F3', 'type': ''}], friendly_name=UE48J6200, entity_picture=None, description=New TV discovered, would you like to add the TV?

![Description image](/static/images/smart-tv.png), submit_caption=Accept @ 2019-02-15T08:58:09.854689+01:00>, new_state=<state configurator.ue48j6200=configured @ 2019-02-15T08:59:22.182931+01:00>>
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=configurator.ue48j6250, old_state=None, new_state=<state configurator.ue48j6250=configure; configure_id=1877922384-2, fields=[{'id': 'pin', 'name': 'Enter the pin', 'type': ''}], friendly_name=UE48J6250, entity_picture=None, description=Enter the Pin shown on your Samsung TV.

![Description image](/static/images/smart-tv.png), submit_caption=Confirm @ 2019-02-15T08:59:22.196080+01:00>>
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'configurator.ue48j6200', 'old_state': <state configurator.ue48j6200=configure; configure_id=1877922384-1, fields=[{'id': 'display_name', 'name': 'Name: UE48J6200', 'type': ''}, {'id': 'description', 'name': 'Description: homeassistant', 'type': ''}, {'id': 'mac', 'name': 'MAC Address : 14:BB:6E:86:CA:F3', 'type': ''}], friendly_name=UE48J6200, entity_picture=None, description=New TV discovered, would you like to add the TV?

![Description image](/static/images/smart-tv.png), submit_caption=Accept @ 2019-02-15T08:58:09.854689+01:00>, 'new_state': <state configurator.ue48j6200=configured @ 2019-02-15T08:59:22.182931+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 22, 183077, tzinfo=<UTC>), 'context': {'id': '4f4665a639944b4286fd4d8e6ed93c17', 'user_id': None}}}
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'configurator.ue48j6200', 'old_state': <state configurator.ue48j6200=configure; configure_id=1877922384-1, fields=[{'id': 'display_name', 'name': 'Name: UE48J6200', 'type': ''}, {'id': 'description', 'name': 'Description: homeassistant', 'type': ''}, {'id': 'mac', 'name': 'MAC Address : 14:BB:6E:86:CA:F3', 'type': ''}], friendly_name=UE48J6200, entity_picture=None, description=New TV discovered, would you like to add the TV?

![Description image](/static/images/smart-tv.png), submit_caption=Accept @ 2019-02-15T08:58:09.854689+01:00>, 'new_state': <state configurator.ue48j6200=configured @ 2019-02-15T08:59:22.182931+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 22, 183077, tzinfo=<UTC>), 'context': {'id': '4f4665a639944b4286fd4d8e6ed93c17', 'user_id': None}}}
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'configurator.ue48j6250', 'old_state': None, 'new_state': <state configurator.ue48j6250=configure; configure_id=1877922384-2, fields=[{'id': 'pin', 'name': 'Enter the pin', 'type': ''}], friendly_name=UE48J6250, entity_picture=None, description=Enter the Pin shown on your Samsung TV.

![Description image](/static/images/smart-tv.png), submit_caption=Confirm @ 2019-02-15T08:59:22.196080+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 22, 196224, tzinfo=<UTC>), 'context': {'id': '631efe228700427c8749a528b6057bf7', 'user_id': None}}}
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'configurator.ue48j6250', 'old_state': None, 'new_state': <state configurator.ue48j6250=configure; configure_id=1877922384-2, fields=[{'id': 'pin', 'name': 'Enter the pin', 'type': ''}], friendly_name=UE48J6250, entity_picture=None, description=Enter the Pin shown on your Samsung TV.

![Description image](/static/images/smart-tv.png), submit_caption=Confirm @ 2019-02-15T08:59:22.196080+01:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 22, 196224, tzinfo=<UTC>), 'context': {'id': '631efe228700427c8749a528b6057bf7', 'user_id': None}}}
2019-02-15 08:59:22 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 22, 'type': 'result', 'success': True, 'result': None}
2019-02-15 08:59:23 DEBUG (SyncWorker_11) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=configurator.ue48j6200, old_state=<state configurator.ue48j6200=configured @ 2019-02-15T08:59:22.182931+01:00>, new_state=None>
2019-02-15 08:59:23 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1853489968] Sending {'id': 61, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'configurator.ue48j6200', 'old_state': <state configurator.ue48j6200=configured @ 2019-02-15T08:59:22.182931+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 23, 12445, tzinfo=<UTC>), 'context': {'id': '8c38798b9a0f4fc0898fa0cefef72027', 'user_id': None}}}
2019-02-15 08:59:23 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1875862416] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'configurator.ue48j6200', 'old_state': <state configurator.ue48j6200=configured @ 2019-02-15T08:59:22.182931+01:00>, 'new_state': None}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 2, 15, 7, 59, 23, 12445, tzinfo=<UTC>), 'context': {'id': '8c38798b9a0f4fc0898fa0cefef72027', 'user_id': None}}}
2019-02-15 08:59:24 INFO (SyncWorker_0) [homeassistant.components.device_tracker.luci] Checking ARP

@cristimi
I am not sure as to why but your TV is not responding to the UPNP SSDP broadcast packets.

@cjsmns
as a reminder the pin entry dialog should appear as a notification. The notification to enter the PIN should be working. if you are not getting a notification then I am going to need to need to do some more work on the detection. possibly parsing the model number. I think that is what I am going to do.

@phairplay
OK so the first piece is tackled. we are now moving onto the power detection once again. I am working on this aspect of it.

It seems to be working fine in HA. I get the notification to enter a name and description, then I get another to enter the PIN from the TV. But I have no PIN displayed on the TV. It seems that the TV is not getting the command to display the PIN.

On a side note, my D series (UA46D6600) hasn't been detected at all. Does this work with D series?

Hi,

I've collected the log as requested here (and made sure the TV was on when I restarted HA!) https://gist.github.com/timdonovanuk/6c52a277d8217f789df299b58c6b006b

The TV is model: UE49KS9000T

Thanks @kdschlosser ! Let me know if you need anything else.

Also calling http://192.168.1.51:7678/nservice/ (my TV) outputs the following:

<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:sec="http://www.sec.co.kr/dlna" xmlns:dlna="urn:schemas-dlna-org:device-1-0"> <specVersion> <major>1</major> <minor>0</minor> </specVersion> <device> <deviceType>urn:dial-multiscreen-org:device:dialreceiver:1</deviceType> <friendlyName>[TV] Samsung 9 Series (49)</friendlyName> <manufacturer>Samsung Electronics</manufacturer> <manufacturerURL>http://www.samsung.com/sec</manufacturerURL> <modelDescription>Samsung DTV RCR</modelDescription> <modelName>UE49KS9000</modelName> <modelNumber>1.0</modelNumber> <modelURL>http://www.samsung.com/sec</modelURL> <serialNumber>20090804RCR</serialNumber> <UDN>uuid:7aa5d94e-51e1-4c69-a10d-76b3e290a918</UDN> <sec:deviceID>NSNSC5ZTTO2RS</sec:deviceID> <sec:ProductCap>Resolution:1920X1080,Tizen,Y2016</sec:ProductCap> <serviceList> <service> <serviceType>urn:dial-multiscreen-org:service:dial:1</serviceType> <serviceId>urn:dial-multiscreen-org:serviceId:dial</serviceId> <controlURL>/RCR/control/dial</controlURL> <eventSubURL>/RCR/event/dial</eventSubURL> <SCPDURL>dial.xml</SCPDURL> </service> </serviceList> <sec:Capabilities> <sec:Capability name="samsung:multiscreen:1" port="8001" location="/ms/1.0/"/> </sec:Capabilities> </device> </root>

OK I updated the code in the first post.

I changed a bunch of things around. IP addresses are no longer needed to define a TV, this means you do not have to set the TV to a static IP address. I am now relying on a UUID that is unique to each TV. With this change It also altered the power detection. I am now using UPNP to detect if the TV is on or not. so the constant trying to open a socket to detect if the TV is on or not is no longer being used. this has reduced the resource use on the device running the code. it would be more noticeable with multiple TV's.
This is a good thing for you folks running on Raspberries. In my setup only running a single TV it has also reduced the memory footprint a few meg.

I also changed the detection mechanism I am now grabbing the year of the TV via UPNP and using the services as a fallback in case the year is not detected properly. This is going to make for a much more solid detection of the connection type.

I did also change up the inputting of the PIN so the notification will be generated after the pin has been displayed on the TV and not before. I think this may have been causing some issues.

the new code is in the first post. everything needed to have it update samsungctl has been set in place.

see this line

<sec:ProductCap>Resolution:1920X1080,Tizen,Y2016</sec:ProductCap>

it only appears on TVs that are 2014 or newer. in that line is the year the TV was made. the Y2016.

if the TV is older then 2014 i use model number parsing the letter in position 5 of the model is the year.
A=2008
B=2009
C=2010
D=2011
E=2012
F=2013

so I know that TV's from 2008 to 2013 are legacy connections. 2014 and 2015 are encrypted websocket
and 2016 and newer are websocket.

and on the 2016 and newer TV's i then check

    http://IPADDRESS:8001/api/v2/

which outputs JSON data in which i look of thee node TokenAuthSupport. if it is there and it is True then it is an ssl websocket connection (port 8002) and of not it is a normal websocket connection (port 8001) but i still use a fallback routine if the connection is on port 8001 and I get ms.channel.unauthorized returned when initially connecting the websocket it will automatically try 8002 anywho.

if by some chance I cannot parse the year i fall back to using UPNP services.

if the TV has these UPNP services
urn:schemas-upnp-org:device:MediaRenderer:1
urn:samsung.com:device:IPControlServer:1
urn:dial-multiscreen-org:device:dialreceiver:1

or these ones
urn:samsung.com:device:RemoteControlReceiver:1
urn:dial-multiscreen-org:device:dialreceiver:1
urn:schemas-upnp-org:device:MediaRenderer:1
it is a 2016+ model

if it has these ones
urn:samsung.com:device:MainTVServer2:1
urn:samsung.com:device:RemoteControlReceiver:1
urn:schemas-upnp-org:device:MediaRenderer:1
urn:dial-multiscreen-org:device:dialreceiver:1

it is a 2014 or a 2015 model

and lastly
urn:schemas-upnp-org:device:MediaRenderer:1
urn:samsung.com:device:MainTVServer2:1
urn:samsung.com:device:RemoteControlReceiver:1
is a <= 2013 model

I am pretty sure the detection code should be pretty rock solid now.

I'll try the new code now, thanks!

If it helps, /api/v2 returns the following on my TV:

{ "id": "uuid:7aa5d94e-51e1-4c69-a10d-76b3e290a918", "name": "[TV] Samsung 9 Series (49)", "version": "2.1.0", "device": { "type": "Samsung SmartTV", "duid": "uuid:7aa5d94e-51e1-4c69-a10d-76b3e290a918", "model": "16_JAZZM_UHD", "modelName": "UE49KS9000", "description": "Samsung DTV RCR", "networkType": "wired", "ssid": "", "ip": "192.168.1.51", "firmwareVersion": "Unknown", "name": "[TV] Samsung 9 Series (49)", "id": "uuid:7aa5d94e-51e1-4c69-a10d-76b3e290a918", "udn": "uuid:7aa5d94e-51e1-4c69-a10d-76b3e290a918", "resolution": "3840x2160", "countryCode": "GB", "msfVersion": "2.1.0", "smartHubAgreement": "true", "VoiceSupport": "true", "GamePadSupport": "true", "wifiMac": "cc:b1:1a:72:53:6e", "developerMode": "0", "developerIP": "", "OS": "Tizen" }, "type": "Samsung SmartTV", "uri": "http://192.168.1.51:8001/api/v2/", "remote": "1.0", "isSupport": "{\"remote_available\":\"true\",\"remote_fourDirections\":\"true\",\"remote_touchPad\":\"true\",\"remote_voiceControl\":\"true\",\"DMP_available\":\"true\",\"DMP_DRM_PLAYREADY\":\"false\",\"DMP_DRM_WIDEVINE\":\"false\",\"EDEN_available\":\"true\"}" }

now you see there is no TokenAuthSupport

so you have a normal websocket connection.

Very nice!

So I got a configuration alert in HA, and it had the right TV model. I now have a media_player.ue49ks9000 entity. I didn't get any alerts on the TV about a pin or anything at that stage.

The media_player.ue49ks9000 entity state showed off when the TV is on. So I hit the "power on" button on the entity, and a popup appeared on my TV asking for permissions from my raspberypi. I hit accept..

But thats it so far, I still just have an media_player.ue49ks9000 entity (that always shows off). Let me know how I can help.

Cheers!

I have been up all night working on this. I have not had any sleep in over 24 hours. I think it is time for me to take a nap for a few hours.

I will work on that issue in a little bit.

making headway tho.. which is a good thing. I need to iron out the kinks in the power portion of it still..

Definitely time for sleep! Take care :)

try manually powering off the TV and then powering the TV back on.. let the TV sit for 2 minutes before powering it back on.

i will hang out for you to try that

Afraid not, did a hard rest of the TV :(

Updated to the new code. No notifications in HA now. I can see in the HA logs (now that I have debug enabled as per above) that it's trying to connect to a few other devices as well, like my Philips Hue hub.

I'll have a look through and see what I can find. I've noticed a few references to links like http://192.168.1.64:7676/smp_2_ with a different number at the end, so smp_15_ smp_25 etc. These seem to be to xml files. Would any of these be of interest? Or a specific one you are after?

EDIT: Acutally, it seems to be just smp_2_, smp_7_, smp_15_ and smp_25_

@kdschlosser Here are my logs https://hastebin.com/tecacuceho.makefile

A new (empty) file was created 937afcea-106a-4fa1-8770-1bXYZd, but no entity was created.

Edit: Just realized most of those are from my Hue. Looks like there was nothing that was captured from the TV (even though it was on)

@cjsmns
I need to see your logs.

@arsaboo
I do not know why your TV is not responding to SSDP packets.

@cjsmns
I need to see your logs.

https://pastebin.com/G91Q0Azn

I've gone through and taken about 2 minutes worth of my log from last night after the last reboot for HA. I've deleted anything not related to samsungctl. There are a few IP address that samsungctl is trying to connect to.

192.168.1.64 is my TV. UA60H6400
192.168.1.195 is my Raspberry Pi with HA and Emulated Hue (I think emulated hue is what it's interacting with)
192.168.1.200 is my Philips Hue Hub.

I've left the interactions with my Pi and Hue hub in just in case you find it handy. You might be able to filter out those interactions. Just a thought.

Hi,
first things first: I am amazed of your good and dedicated work and really want to say "thank you" for it!

I just did some testing with your code and my TV (UE55MU6179). I see the entity being created, the power state seems to be displayed correctly and the TV asks for the remote control permission. It can be even switched off from home assistant - looks fine until now:

When trying to switch the tv on (or do any other interaction), "nothing" happens. I've taken a look into the log and noticed several exceptions. I pasted them here: https://pastebin.com/nCntsB5g

In action.py on line 119 of the latest dev branch of samsungctl I see, that there is an try/except clause for a ParseError - but according to the stacktrace, there may also be an ValueError being thrown (although I'm not sure, if it should be treated just like a ParseError or differently).

UPDATE:
When attempting to fix the problem like this (samsungctl/upnp/UPNP_Device/action.py line 118 and following; taken from develop-branch):

        try:
            envelope = etree.fromstring(response)
        except etree.ParseError:
            return [None] * len(self.ret_vals)
        except ValueError:
            try:
                utf8_parser = etree.XMLParser(encoding='utf-8')
                envelope = etree.fromstring(response, parser=utf8_parser)
            except etree.ParseError:
                logger.error(self.__name__ + ' Fix not working for response: ' + response)
                return [None] * len(self.ret_vals)

the TV is being switched on. But immediately after, I see the websocket being closed with status 31522 and homeassistant still showing the device in state off (and therefore not being able to send any commands to it).

people. I need to see the full logs. from the time hass starts until the time you stop it. a chunk cut out of the middle of it is not going to help me at all. I also need to see what hass is doing.

there are lines like this one for instance. that is generated by hass. but is caused by the samsungtv code

2019-02-15 17:45:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=configurator.un55d8000, old_state=None, new_state=<state configurator.un55d8000=configure; configure_id=87196616-1, fields=[{'id': 'display_name', 'name': 'Name: UN55D8000', 'type': ''}, {'id': 'description', 'name': 'Description: OFFICE-PC', 'type': ''}, {'id': 'mac', 'name': 'MAC Address : D0:66:7B:A3:DD:0E', 'type': ''}], friendly_name=UN55D8000, entity_picture=None, description=New TV discovered, would you like to add the TV?

I need to see all of it. not just bits and pieces.

@maxkde
TY for the complete post of the traceback. i do appreciate it.

I think because of the way samsung TV's reply encoding is different between years/models as well as different based on the function. we are going to need to do some exception catching here.

so starting at line 114 in action.py which reads

        response = response.content.decode('utf-8')

        logger.debug(self.__name__ + ' <-- ' + response)

        try:
            envelope = etree.fromstring(response)
        except etree.ParseError:
            return [None] * len(self.ret_vals)

        envelope = strip_xmlns(envelope)

        body = envelope.find('Body')

        return_value = []

we need to change that to

        logger.debug(self.__name__ + ' <-- ' + response.content.decode('utf-8'))

        try:
            envelope = etree.fromstring(response.content.decode('utf-8'))
        except ValueError:
            try:
                envelope = etree.fromstring(response.content)
            except etree.ParseError:
                return [None] * len(self.ret_vals)
        except etree.ParseError:
            return [None] * len(self.ret_vals)

        envelope = strip_xmlns(envelope)

        body = envelope.find('Body')

        return_value = []

what is causing the issue is this. if the opening tag in the returned xml is this

<?xml version="1.0"?>

then the input needs to be a string. and because response.content in python 3 are bytes we need to decode the information before feeding it into lxml

Now when the return data has this as the first tag

<?xml version="1.0" encoding="UTF-8"?>

the data fed into lxml needs to be bytes.

it's a crap shoot what TV is going to return what tag as well as the function. some functions may return the encoding some may not.

ya gotta love the dumb ass programmers at Samsung.. they have ZERO consistency

as far as the serializing issue that is easily corrected as well.

line 434 in the code attached to the first post would need to be changed to

self._entity_image = "".join(map(chr, list(entity_image)))

people. I need to see the full logs. from the time hass starts until the time you stop it. a chunk cut out of the middle of it is not going to help me at all. I also need to see what hass is doing.

Sorry, I didn’t realise that everything else HA does affects samsungctl. I will restart HA some time in the next day and grab some fresh logs for you.

Is there a way to PM the logs to you? I don’t want them online for the world to see.

@kdschlosser Thanks for all your work, it is amazing what you are doing.

I am attaching my full home assistant log, and here some comments of my test:

TV: UN32J5500 year 2015
Home Assistant V0.87.0
configuration.yaml:

media_player:
  - platform: samsungtv

logger:
    default: debug
    logs:
      media_player.samsungtv: debug
      samsungctl: debug

Home Assistant log:
Full home assistant log UN32J5500.txt

I added your code on the first post on:
/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/media_player/samsungtv.py

When home assistant starts it shows a notification that a TV is found, it ask me for name, description and MAC, I accept it, but nothing happend, no message on the TV asking for pin or authorization.
I even tried addind the host of my tv to configuration.yaml, with the same results.

I hope this information helps you.

Thanks.

The full log is going to tell me what is getting run and when and also any information like what i posted above which is generated by hass for the notification to add the TV.

I believe I know where the issue is in regards to the TV not showing the authentication accept or pin.

I am working on a series of notifications. if you have a 2014 or 2015 model TV it will ask you if you want to add the TV. and if you do add the TV then another notification will get displayed asking you to enter the pin. if you have any other model there will bee a notification letting you know to accept the pairing on the TV.

I would much rather do everything in the same notification box. meaning just update the content of it. I am not sure if this is possible. That would be the best way to handle it instead of having a new notification for each step that has to take place. I say this because I know that hass sometimes can take a while to update. and in most cases the timeout period on the TV for accepting the control or entering the pin is about 30 seconds which is not a long time.

I have to do alittle more looking into why the initial pairing exits with a failed status when it was never completed. that is the issue I am having at the moment. I will get it sorted out. I do know this is the better way to go about handling when to connect and disconnect the websocket and to disable the UPNP end of things. I am going to have to add some more debugging steps to see what is going on in the data path.

I was add samsungtv.py in my_dir_config/custom_components/media_player/samsungtv.py
Where can I placed new samsungctl? I was install my HA on docker.

i updated to the latest version
it creates a folder but its empty
no notification on HA
no notification on my tv

it did work a few versions back
do you need a log?

Getting this error now:

2019-02-16 20:31:55 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 257, in _async_add_entity if entity.unique_id is not None: File "/usr/src/app/homeassistant/components/media_player/samsungtv.py", line 531, in unique_id return '{' + self._config.uuid + '}' TypeError: must be str, not NoneType

I was add samsungtv.py in my_dir_config/custom_components/media_player/samsungtv.py
Where can I placed new samsungctl? I was install my HA on docker.

Since @kdschlosser will not respond probably:
Read the first post properly:

If you state anything about "custom_components" or if i see that in any of the errors I am not going to answer you. this is because you have modified the code. and it is a pretty good chance that your modification is what is causing the problem.

@ThaStealth samsungctl will be automatically installed as it has the requirements specified.

Also, I got the same error. Delete the samsung_tv folder manually and restart HA @ThaStealth

That error is because of an old config file kicking about.

I am working on adding more logging to the thing. I am trying to figure out where the problem is. I know it is somewhere between the initial discovery and the thing getting added. So what I am doing is if the TV has not been paired yet I am going to have it do that before adding the entity.

Here is my log with older (2013) Samsung TV ha-log-UE46F6400.txt
Paired nicely, got the auth popup on the TV screen. However after turning the television off it seems to be turned off for 20 or so seconds and Home Assistant shows it being on again even TV is actually turned off.

OK this is what I am going to do. I am going to spend more time adding to the unittests. I have to add the encrypted TV's to the tests. I also need to come up with a tests for checking the power state of the TV.s It is going to take me a while to get that done here is a lot involved in making the unittests.

so we are going to b on hold for a bit with this. sorry folks. I need a better way of testing. If i has 2 people one with a 2016+ TV and someone with a 2014/2015 TV that knows python and has the ability to install and run just python without home assistant things would be a bit easier.

Sorry I haven't got my full HA logs to you. I've been rather busy over the weekend. If you still want/need them, let me know and I'll reboot HA and my TV and capture a few minutes worth.

so we are going to b on hold for a bit with this. sorry folks. I need a better way of testing. If i has 2 people one with a 2016+ TV and someone with a 2014/2015 TV that knows python and has the ability to install and run just python without home assistant things would be a bit easier.

I have a 2014 H series, but I'm not skilled enough with Python. Happy to test things out, but that's as far as my skill set goes at the moment. :pensive:

I have a 2014 H6400 and I know Python. @kdschlosser, if you tell me what I have to do, i will do it.

I prefer testing without Home Assistant, because Hass.io is complicated to test and I have lots of components workings on it, and I do not want them to stop working (every change we have to reboot the server...)

So, tell me what I have to execute, I will do it, and I will pass the result and the logs.

Thanks for the effort :-)

@sermayoral

OK so first thing is first.. I need you to be on slack if you are not already. If you are not then click the link below.

https://join.slack.com/t/samsungtvcontrol/shared_invite/enQtNTUzMDQ4ODY1MDk0LTA0Yjk3OTIwZWM0ODdmODFiMGEyNzg1OTBlZWI2YzEyYzNiMThiOTg0MDQxNDJiMjRlN2RiMDYzY2UzNjQwNTg

I need to know a few things and I am also going to have to have you do a few things.

How familiar are you with python?
Is the computer you are going to run the tests from the same computer that you will be able to use slack chat from?
What is the OS of the computer you wiil be able to run the tests from?

I am going to need you to install python 2.7 and also python 3.x

do you want me to write a program to automate my tests? if so I am going to need to know the path where you want me to read/write/delete data from.

if you are using Windows. do you know how to change the console(command line) output buffer? or Will you be using an IDE to run the tests from? If you are using an IDE do you know how to change the output buffer of the IDE's console window?. I ask the questions about the buffer because there is going to be a large amount of data that is going to get printed out to the screen. so you will most likely not be able to scroll back to the beginning unless you increase the buffer to say 10000 lines.

what times are you available to do the testing? (your local time)
my tz is GMT -7:00 (Mountain Time United States) what is yours?

I prefer testing without Home Assistant, because Hass.io is complicated to test

I 100% agree with this statement.

I have a 2014 H6400 and I know Python.

This is good. I have the same TV. Hopefully you guys can get this working. Let me know if you need another person to test from an end users perspective if needed.

@kdschlosser

_How familiar are you with python?_

I'm a computer engineer, but usually works in Java. I learnt python for pleasure. I've made some Python scripts for web data mining using the regex library. I'm not an expert in Python. However, I believe that I am capable of executing any program and interpreting the result.

_Is the computer you are going to run the tests from the same computer that you will be able to use slack chat from?_

Yes, it is.

_What is the OS of the computer you wiil be able to run the tests from?_

Windows 10.

_I am going to need you to install python 2.7 and also python 3.x_

Perfect. Right now i have installed Python 3.7.2, but I'm going to install version 2.x right now

_do you want me to write a program to automate my tests? if so I am going to need to know the path where you want me to read/write/delete data from._

Perfect. For example C:tests

_if you are using Windows. do you know how to change the console(command line) output buffer? or Will you be using an IDE to run the tests from? If you are using an IDE do you know how to change the output buffer of the IDE's console window?. I ask the questions about the buffer because there is going to be a large amount of data that is going to get printed out to the screen. so you will most likely not be able to scroll back to the beginning unless you increase the buffer to say 10000 lines._

Im using a command line, so I suppose the ideal would be to redirect the output to a text file. I'm going to look at how it's done in Python.

Edit: In the program you write to automate your test, use this:

sys.stdout = open("C:/tests/output.txt", "w+");

_what times are you available to do the testing? (your local time)
my tz is GMT -7:00 (Mountain Time United States) what is yours?_

I'm from Spain. UTC/GMT+1. Right now is the 11.54 pm. There are 8 hours apart. I will be available every day from your 12 pm (GMT-7) until the dream can with me hehe ( 5 or 6 pm)

If someone has a Samsung TV other than the H6400 model, knows a bit about Python and wants to help test the component, please let us know it. 😊

@sermayoral

i have it outputting the information to the file requested. I sent you an updated version of samsungctl along with the program for running the tests.

to increase the output buffer of a command prompt if you click on the small icon in the caption bar on the top left of the window. you should see preferences in the drop down menu. in the properties dialog you should have a tab for "Layout". this is where you will be given the controls to adjust the buffer.
you can also adjust the number of columns and rows that are displayed as well.

I have a UN75NU8000 that I can test with

These tests are run from python. and not Home Assistant. I need to iron out the kinks in samsungctl. HomeAssistant is adding an extra layer of complexity that is making it difficult to isolate problems. the tests need to be run using Python 2 and 3.

If you are willing to do this then you need to join the slack chat and send me a PM letting me know what the model number of your TV is what OS the device is running that the tests are going to be performed from.
I am also going to need the absolute path to where the output can be saved.

I will then send a zipped up version of samsungctl that will include the script that needs to be run. the output path will be coded into the script. it is completely automated except for entering a pin on encrypted TV and accepting the connection on all others.

the script is going to need to be run using python 2.7 and the output files sent to me in a PM using slack chat. the tests will also need to be run using Python 3.6 or 3.7 and the output also sent to me.

You will not need to install anythign using pip. I have done my best to remove as much user interaction as possible.

@kdschlosser Perfect. When I leave work I will try your script.

I know how to increase the output buffer, but I thought that redirecting the I/O flow to a file would be better. However, I will increase the output buffer as indicated :-)

@arsaboo Thanks for your help. Please join the slack chat with us :-)

I have a UE55NU8006 and am willing to help with testing. Joined the slack chat already :) @kdschlosser I've sent you a DM on slack.

@kdschlosser I’ll be glad to help. I’ve got a QE65Q8FAMT

I have a HU7500 and basic knowledge about Python (but I'm a developer)

Thanks to everyone for your collaboration.

@ThaStealth It's enough. However, if we have any doubts then we can solve it among all by Slack.

For all interested, you must join the following slack group:

https://join.slack.com/t/samsungtvcontrol/shared_invite/enQtNTUzMDQ4ODY1MDk0LTA0Yjk3OTIwZWM0ODdmODFiMGEyNzg1OTBlZWI2YzEyYzNiMThiOTg0MDQxNDJiMjRlN2RiMDYzY2UzNjQwNTg

And send a PM to @kdschlosser telling him the model number of your TV, what OS the device is running that the tests are going to be performed and the absolute path to where the output can be saved (e.g. "/home/tests", "C:/tests", ....)

Is there need for testing with devices that are older than 2014? I could give a shot with my 2013 Samsung if that is needed.

Hi,

I have a F7000 (2013).
If I can help, just tell me.


I've tried the code, and it does not give me an error, but I'm missing features that do have my current custom_component

"""
Support for interface with an Samsung TV.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.samsungtv/
"""
import asyncio
from datetime import timedelta
import logging
import socket

import voluptuous as vol

from homeassistant.components.media_player import (
    MEDIA_TYPE_CHANNEL, PLATFORM_SCHEMA, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
    SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_TURN_OFF,
    SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
    MediaPlayerDevice)
from homeassistant.const import (
    CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_TIMEOUT, STATE_OFF)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import dt as dt_util

REQUIREMENTS = ['samsungctl[websocket]==0.7.1', 'wakeonlan==1.1.6']

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Samsung TV Remote'
DEFAULT_PORT = 55000
DEFAULT_TIMEOUT = 1

KEY_PRESS_TIMEOUT = 1.2
KNOWN_DEVICES_KEY = 'samsungtv_known_devices'

SUPPORT_SAMSUNGTV = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \
    SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | \
    SUPPORT_NEXT_TRACK | SUPPORT_TURN_OFF | SUPPORT_PLAY | SUPPORT_PLAY_MEDIA

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
    vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Samsung TV platform."""
    known_devices = hass.data.get(KNOWN_DEVICES_KEY)
    if known_devices is None:
        known_devices = set()
        hass.data[KNOWN_DEVICES_KEY] = known_devices

    uuid = None
    # Is this a manual configuration?
    if config.get(CONF_HOST) is not None:
        host = config.get(CONF_HOST)
        port = config.get(CONF_PORT)
        name = config.get(CONF_NAME)
        mac = config.get(CONF_MAC)
        timeout = config.get(CONF_TIMEOUT)
    elif discovery_info is not None:
        tv_name = discovery_info.get('name')
        model = discovery_info.get('model_name')
        host = discovery_info.get('host')
        name = "{} ({})".format(tv_name, model)
        port = DEFAULT_PORT
        timeout = DEFAULT_TIMEOUT
        mac = None
        udn = discovery_info.get('udn')
        if udn and udn.startswith('uuid:'):
            uuid = udn[len('uuid:'):]
    else:
        _LOGGER.warning("Cannot determine device")
        return

    # Only add a device once, so discovered devices do not override manual
    # config.
    ip_addr = socket.gethostbyname(host)
    if ip_addr not in known_devices:
        known_devices.add(ip_addr)
        add_entities([SamsungTVDevice(host, port, name, timeout, mac, uuid)])
        _LOGGER.info("Samsung TV %s:%d added as '%s'", host, port, name)
    else:
        _LOGGER.info("Ignoring duplicate Samsung TV %s:%d", host, port)


class SamsungTVDevice(MediaPlayerDevice):
    """Representation of a Samsung TV."""

    def __init__(self, host, port, name, timeout, mac, uuid):
        """Initialize the Samsung device."""
        from samsungctl import exceptions
        from samsungctl import Remote
        import wakeonlan
        # Save a reference to the imported classes
        self._exceptions_class = exceptions
        self._remote_class = Remote
        self._name = name
        self._mac = mac
        self._uuid = uuid
        self._wol = wakeonlan
        # Assume that the TV is not muted
        self._muted = False
        # Assume that the TV is in Play mode
        self._playing = True
        self._state = None
        self._remote = None
        # Mark the end of a shutdown command (need to wait 15 seconds before
        # sending the next command to avoid turning the TV back ON).
        self._end_of_power_off = None
        # Generate a configuration for the Samsung library
        self._config = {
            'name': 'HomeAssistant',
            'description': name,
            'id': 'ha.component.samsung',
            'port': port,
            'host': host,
            'timeout': timeout,
        }

        if self._config['port'] == 8001:
            self._config['method'] = 'websocket'
        else:
            self._config['method'] = 'legacy'

    def update(self):
        """Update state of device."""
        self.send_key("KEY")

    def get_remote(self):
        """Create or return a remote control instance."""
        if self._remote is None:
            # We need to create a new instance to reconnect.
            self._remote = self._remote_class(self._config)

        return self._remote

    def send_key(self, key):
        """Send a key to the tv and handles exceptions."""
        if self._power_off_in_progress() \
                and key not in ('KEY_POWER', 'KEY_POWEROFF'):
            _LOGGER.info("TV is powering off, not sending command: %s", key)
            return
        try:
            # recreate connection if connection was dead
            retry_count = 1
            for _ in range(retry_count + 1):
                try:
                    self.get_remote().control(key)
                    break
                except (self._exceptions_class.ConnectionClosed,
                        BrokenPipeError):
                    # BrokenPipe can occur when the commands is sent to fast
                    self._remote = None
            self._state = None
        except (self._exceptions_class.UnhandledResponse,
                self._exceptions_class.AccessDenied):
            # We got a response so it's on.
            self._state = None
            self._remote = None
            _LOGGER.debug("Failed sending command %s", key, exc_info=True)
            return
        except OSError:
            self._state = STATE_OFF
            self._remote = None
        if self._power_off_in_progress():
            self._state = STATE_OFF

    def _power_off_in_progress(self):
        return self._end_of_power_off is not None and \
               self._end_of_power_off > dt_util.utcnow()

    @property
    def unique_id(self) -> str:
        """Return the unique ID of the device."""
        return self._uuid

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def is_volume_muted(self):
        """Boolean if volume is currently muted."""
        return self._muted

    @property
    def supported_features(self):
        """Flag media player features that are supported."""
        if self._mac:
            return SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON
        return SUPPORT_SAMSUNGTV

    def turn_off(self):
        """Turn off media player."""
        self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)

        if self._config['method'] == 'websocket':
            self.send_key('KEY_POWER')
        else:
            self.send_key('KEY_POWEROFF')
        # Force closing of remote session to provide instant UI feedback
        try:
            self.get_remote().close()
            self._remote = None
        except OSError:
            _LOGGER.debug("Could not establish connection.")

    def volume_up(self):
        """Volume up the media player."""
        self.send_key('KEY_VOLUP')

    def volume_down(self):
        """Volume down media player."""
        self.send_key('KEY_VOLDOWN')

    def mute_volume(self, mute):
        """Send mute command."""
        self.send_key('KEY_MUTE')

    def media_play_pause(self):
        """Simulate play pause media player."""
        if self._playing:
            self.media_pause()
        else:
            self.media_play()

    def media_play(self):
        """Send play command."""
        self._playing = True
        self.send_key('KEY_PLAY')

    def media_pause(self):
        """Send media pause command to media player."""
        self._playing = False
        self.send_key('KEY_PAUSE')

    def media_next_track(self):
        """Send next track command."""
        self.send_key('KEY_FF')

    def media_previous_track(self):
        """Send the previous track command."""
        self.send_key('KEY_REWIND')

    async def async_play_media(self, media_type, media_id, **kwargs):
        """Support changing a channel."""
        if media_type != MEDIA_TYPE_CHANNEL:
            _LOGGER.error('Unsupported media type')
            return

        # media_id should only be a channel number
        try:
            cv.positive_int(media_id)
        except vol.Invalid:
            _LOGGER.error('Media ID must be positive integer')
            return

        for digit in media_id:
            await self.hass.async_add_job(self.send_key, 'KEY_' + digit)
            await asyncio.sleep(KEY_PRESS_TIMEOUT, self.hass.loop)

    def turn_on(self):
        """Turn the media player on."""
        if self._mac:
            self._wol.send_magic_packet(self._mac)
        else:
            self.send_key('KEY_POWERON')

image

image

Are still testers needed?
I'd also volunteer to run some tests. My TV is a UE55MU6179 (I think that's model year 2017, but not 100% sure about that).

UE55MU6179 = 2016

System: UN55NU8000 with Home Assistant 0.87.1 running via HassIO on a RPi 3B+

I can add the TV via the notification that pops up for the Configurator. After filling out the necessary information, a notification appears on the TV requesting access. I can then refresh the HassIO frontend to see the entity. However, the state is incorrect and the entity does not respond to any commands and the entity disappears completely after I reboot. Additionally, only the .noinclude file is successfully created in the samsung_tv folder.

Here is my full log: home-assistant.log

I wanted to let everyone know where we are at with this an not leave ya hanging.

OK so here is the skinny. discovery is working like a champ now. I found out where the issue wa and it is now all sorted out. I am still working out some bugs in the power portion of the program. I think I may have found what the cause is just waiting on a test. websocket, SSL websocket and encrypted are working good. i broke the legacy somehow. still looking into what I did there. all the issues with UPNP have been resolved. I only have the channels to deal with and the UPNP i am almost sure can be stamped COMPLETE. the config portion is working good. no problems there. after i fix the few issues and do up the channels and run some more tests across the 5-6 different models that people are running these tests on if everything works smoothly then I know the backend of the library is functioning like it should and I can move back to working on the hass portion. I would really like to expose more of what these TV's can do to hass. But I need help doing that. the controls that hass gives doesn't even scratch the surface of the control that is available. and I do not own any of the components in the components portion of the program. if i did I would be able to load the component and see how thee GUI is done for those items. I guess I could "hotwire" the things so they would display. That is quite a bit of work to do. I need a visual comparison to see if i can make something work for the samsung tv's
So again if there is someone out there that is really knowledgeable about hass and the different "flows" and things of that nature. I could really use the help on that end of it.

thanks for keeping us informed

Thanks for the update. Can’t wait to take control of my H series and my D series TV’s.

I have quite some Python knowledge but no knowhow about interal flow of the HA GUI and suchlike. I have a Samsung The Frame, and can't wait to have it implemented in HA. If I can help just let me know..

Hi,
I've tried the latest version available, and I still have fewer functions than what I'm currently using

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/media_player/samsungtv.py

Regards

@Onandon11

I need to work with you and your TV one on one. I have a bunch of websocket commands that are specific to "Frame" TV's I need to have them tested for one. But for 2 I am going to have you put your TV into what is called "developer" mode. which is basically a debugging mode. It is going to enable you to connect to the TV on a special IP address and you will be able to view/download communications log files from the TV. This is a very important thing. what you so is once that mode is enabled you thn load up the smart things application. and on at a time you go through every single menu/option/setting in the app that is for thee TV.. and I do mean everything. the websocket commands get logged to that debugging mode. This could be the lynch pin for things like changing the source and changing channels. possibly getting guide data from the TV. or enumerating content on a USB drive. You have to test everything. I have only been able to get small bits and pieces of these logs. never one where someone did the above.
then you will save the log from the TV and then disconnect the smart things app. then clear thee log on the TV. I have a test program i am going to want you to run. this is going to go through each and every single feature and function the current samsungctl supports. and once that is done then save that log file from the TV.

would this be something you are willing to do?

if so click the link blow to join slack chat. and send me a PM. I will get the necessary information over to ya.

https://join.slack.com/t/samsungtvcontrol/shared_invite/enQtNTUzMDQ4ODY1MDk0LTA0Yjk3OTIwZWM0ODdmODFiMGEyNzg1OTBlZWI2YzEyYzNiMThiOTg0MDQxNDJiMjRlN2RiMDYzY2UzNjQwNTg

@LeidenSpain

this is still an alpha test version. it does not function properly yet. as you can see from the posts I am trying to get as many features from these TV's as possible. I am really thinking to going out and buying one for 2 weeks and then return it.

on my legacy everything works perfect. but it is different mechanics then the websocket TV's

@LeidenSpain

this is still an alpha test version. it does not function properly yet. as you can see from the posts I am trying to get as many features from these TV's as possible. I am really thinking to going out and buying one for 2 weeks and then return it.

on my legacy everything works perfect. but it is different mechanics then the websocket TV's

Do not worry, I understand perfectly that programming something is not easy, and more when there are so many differences between some models or others.
I have already activated the developer mode on my TV (F7000), in case it helps.
I have also accessed the assistance menu.

Regards

I wanted to throw something out there as an idea. Some time ago I wrote an API for liibcec. for those of you that do not know what libcec is, it is a software package for accessing a CEC interface device. Pulse Eight makes one of these devices. and one is built into Raspberry Pi. Seeing as how a lot of you folks are using raspberry pi's I thought this would be a geat feature to add into samsungctl. for starters this would give you the direct source change that most of you would like to have. We can also capture events for button presses on the remote. the samsungctl volume control would change over to using libcec for the volume control. so if you have a CEC complient AVR the volume would change on that instead of the TV.

what are the thoughts on that??

You're so creative thinking every possibilities, I like the idea of capturing remote key. In my automations with Home assistant; So if I pause a movie, the lights magically open. I dream about that for years :-D thanks for your work, that's impressive.

The phrase "It cannot be done." does not fit into my vocabulary. because the person saying it is actually saying "I am to lazy to figure it out.", I will however accept a substitute of "Given our state of technology at the present time we cannot make it happen." This is a good replacement because it is not saying that it can't be done. it is saying it can't be done right now but in the future, yes.

I have been told my bean does a very good job at solving problems or coming up with crafty ways to accomplish a goal.

Now as far as the remote button eventing.. I know this in fact does work with Samsung TV's (It's a crap shoot as to what brands do and don't) I have tested it with my Samsung TV. That is not to say that the dingbats over at Samsung didn't remove this feature in newer models. I do not have that answer.

The other things is how does one go about creating something the automation pieces of hass can use. That I do not know. so if someone is willing to chime in and explain this system to me then we can have a go at it.

So if I'm following the most recent discussions with the CEC stuff on the pi would that require the pi to be connected to the TV? Also how would it effect those of us not using a pi (I'm running on a Xeon server)?

@LeidenSpain

I understand perfectly that programming something is not easy

Actually programming is quite easy. what is not so easy is the elimination of bugs. This becomes exceedingly difficult when trying to interface with a device and there is no documentation for the device end of the interface, and then to top it off not having the device in hand to test against make it even more of a nightmare.

@Chaotic

Raspberry Pi's happen to have the CEC control built into them that is why I mentioned it. But so long as you have a CEC adapter like this one https://www.pulse-eight.com/p/104/usb-hdmi-cec-adapter that can be purchased for 45.00 USD it will work. You will need to check libcec and see what adapters are supported before making a purchase. I know thee Pulse eight one works as well as the one built onto a Raspberry PI.

By design CEC travels over an HDMI cable. so yes the Raspberry Pi or any CEC adapter for that fact will need to be plugged into the HDMI port. Now.. I would have to go back and check but I do not believe it needs to be plugged into the TV. It simply has to be plugged into the CEC bus. so if you have your TV plugged into an AVR you should be able to plug the adapter into the AVR or the TV

So if you have a 2018 model TV and you have the CEC adapter you will be given a list of sources to select from. and if all goes well in the automation end of things you will get notifications when buttons are pressed on the TV's remote. If you do not have the CEC Adapter you will not be given the ability to select the source. you will only be able to cycle through the sources. and there will be no events for button presses.

If you happen to own a TV that does not support being powered on over the network and you have a CEC adapter then the TV will be able to be powered on..

For what it's worth, I own a Q7F, and I have the same no power off issue. Here is the error I get:

samsungctl.exceptions.UnhandledResponse: {'event': 'ms.channel.unauthorized'}

And I guess that means somehow the communication with the TV has broken down for this one operation.

Here is the full stack trace:

2019-02-25 22:17:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 289, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/samsungtv.py", line 214, in turn_off
    self.get_remote().close()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/samsungtv.py", line 138, in get_remote
    self._remote = self._remote_class(self._config)
  File "/usr/local/lib/python3.7/site-packages/samsungctl/remote.py", line 11, in __init__
    self.remote = RemoteWebsocket(config)
  File "/usr/local/lib/python3.7/site-packages/samsungctl/remote_websocket.py", line 30, in __init__
    self._read_response()
  File "/usr/local/lib/python3.7/site-packages/samsungctl/remote_websocket.py", line 72, in _read_response
    raise exceptions.UnhandledResponse(response)
samsungctl.exceptions.UnhandledResponse: {'event': 'ms.channel.unauthorized'}

Hi,

I have updated to home assistant 0.88.1 and now my samsungtv.py no longer gives the option to pause.
In case the information helps you, or you want me to do some test with your custom_component

Regards

I have Q7FN and Q9FN, who want to test please let me know.
This not work anymore with 0.88.1 so i could not test

Hi,

This is my system:
image

I'm using this version of samsungtv.py but it has a dependency problem,
Then, I have tried to update the samsungctl:
https://github.com/kdschlosser/samsungctl

But the same error:

Error loading custom_components.samsungtv.media_player. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 147, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv/media_player.py", line 13, in <module>
    from homeassistant.components.media_player import (
ImportError: cannot import name 'MEDIA_TYPE_CHANNEL'

And now, I have the same error with all samsungtv.py versions (oficial, beta, custom,...)

Hi
using the data of the component alexa.py that if it works for me, I have managed to avoid dependency errors:
https://community.home-assistant.io/t/native-support-for-android-tv-android-devices/82792/173

from homeassistant.components.media_player import (
    MediaPlayerDevice, MEDIA_PLAYER_SCHEMA, PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (
    MEDIA_TYPE_CHANNEL, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
    SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_TURN_OFF,
    SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP,
    SUPPORT_VOLUME_SET, SUPPORT_SELECT_SOURCE)
from homeassistant.const import (
    CONF_NAME,
    STATE_OFF,
    STATE_ON)
from homeassistant.const import (
    STATE_IDLE, STATE_STANDBY, STATE_PAUSED,
    STATE_PLAYING)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import dt as dt_util

keeps giving off always (as with the official component), but no longer gives dependency errors.

I will be updating the samsungctl library some time today. I will also update the code in the first post to work with the updated library.

the only thing you need to do is go into components/media_player/samsungtv.py delete all of the code in that file and paste in the code that is attached to the first post. it will update the samsungctl library as needed.

Super, will test it tonight! When you said you'll update the samsungctl library, does is it mean that you maintain the Ape library or we need to replace HA library with yours? Sorry for my noobness ;)

Just realize that your samsungtv.py will download the source from your repo. Sry

Hi, I just have a quick question. I installed the samsungctl library using terminal, and just want to know how do I actually use that code you wrote. Where do I save it, how do I use it etc. Thanks in advance.
Am I supposed just to replace the code in that file with this one in the thread?

Super, will test it tonight! When you said you'll update the samsungctl library, does is it mean that you maintain the Ape library or we need to replace HA library with yours? Sorry for my noobness ;)

Just realize that your samsungtv.py will download the source from your repo. Sry

The code in the first post will download his version. The maintainer of the Ape library has gone awol and his was forked from that (and then new features added) IIRC he is trying to iron out all the bugs then it will be added to pippy and a PR done on the code for HA to replace the current samsungtv with his version.

hass.io users:

go to the location where the configuration.yaml file is located
open the custom_components folder
open the media_player folder if it exists. if not make it.
create a new fil called "samsungtv.py" thne paste the code form the first post into that new file.
restart hass.io

for homeassistant users (pip install of homeassistant)
open up your python site-packages folder.
from there navigate to the folder homeassistantcomponentsmedia_player
open the samsungtv.py file.
select everything in the file and press delete
past in the code form the first post.
save the file and restart homeassistant.

thee code form the first post contains all of the code needed to download the version of samsungctl from my Github repository that is needed. when I update the code if you already have samsungctl installed into homeassistant it is going to upgradedowngrade it to the version that is needed.

@kdschlosser The constants have moved in 0.88. The following should work:

from homeassistant.components.media_player import (
    PLATFORM_SCHEMA, MediaPlayerDevice)
from homeassistant.components.media_player.const import (
    SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_PLAY_MEDIA,
    SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_VOLUME_SET,
    SUPPORT_SELECT_SOURCE, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE,
    SUPPORT_VOLUME_STEP, MEDIA_TYPE_CHANNEL)

Also, the path of the file should change to /config/samsungtv/media_player.py. It will work as-is for now, but folks will see this warning:

Log Details (WARNING)
Wed Feb 27 2019 14:54:05 GMT-0500 (Eastern Standard Time)
Integrations need to be in their own folder. Change media_player/samsungtv.py to samsungtv/media_player.py. This will stop working soon.

I have been following this issue for a while, and decided to try it now. I changed the samsungtv.py code as described, but I get the following error. Currently on the latest version of hassio. Also changed the parts of code as mentioned in the post above.

Error while setting up platform samsungtv Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform SLOW_SETUP_MAX_WAIT, loop=hass.loop) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for return fut.result() 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/media_player/samsungtv.py", line 103, in setup_platform from samsungctl.upnp.discover import auto_discover ModuleNotFoundError: No module named 'samsungctl.upnp'

Regarding the samsungctl, I am still confused if I manually need to install/delete something before the custom samsungtv.py works properly.

samsungctl should be installed automatically. On Hassio, you can check the deps directory to see if it is installed.

Thank you for the quick reply. After three restarts it now suddenly works.

I am at work and will be some time before I can test it out. But can you confirm which TV you are testing this on and how well it is working for you?

My model is: Samsung UE49MU6175

The celebration was short. Suddenly after connection with the TV (i input the MAC address as well during setup) I was able to change volume with the slider. However, no of the other functionality worked. After one more restart of hassio the TV showed as "off", and no actions was possible. My TV prompted me to allow the connection after both restarts.

Logs mention some problems with serializing/parsing JSON and fetching of status from TV took too long. Disabled it until further as stability suffered, but I will try again tomorrow hopefully.

Please paste any errors/logs that you see for @kdschlosser to debug.

I'll hopefully find time to test this out tonight. Looking forward to getting it working. Thanks for all the hard work @kdschlosser.

Hi,

Sorry, but i have the same old problem: the player is on only 10 seconds, and later disable some options.

I'm using the last version of all:

pip install --no-cache-dir "https://github.com/kdschlosser/samsungctl/archive/develop.zip#samsungctl==0.8.64b"
samsungctl --version
samsungctl 0.8.64b



md5-c3cceea15f8e8b740d77d5b0c7c5cdfa



Wed Feb 27 2019 22:09:35 GMT+0100 (hora estándar de Europa central)
Error loading custom_components.samsungtv.media_player. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 147, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv/media_player.py", line 16, in <module>
    from homeassistant.components.media_player import (
ImportError: cannot import name 'MEDIA_TYPE_CHANNEL'



md5-f03005ab873b860e6974ce7054bbfbba



"""
Support for interface with an Samsung TV.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.samsungtv/
"""
import asyncio
from datetime import timedelta
import logging
import socket

import voluptuous as vol

from homeassistant.components.media_player import (
    MediaPlayerDevice, MEDIA_PLAYER_SCHEMA,
    PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (
    MEDIA_TYPE_CHANNEL, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
    SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_TURN_OFF,
    SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP)
from homeassistant.const import (
    CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_TIMEOUT, STATE_OFF)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import dt as dt_util

REQUIREMENTS = ['samsungctl[websocket]==0.7.1', 'wakeonlan==1.1.6']

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Samsung TV Remote'
DEFAULT_PORT = 55000
DEFAULT_TIMEOUT = 1

KEY_PRESS_TIMEOUT = 1.2
KNOWN_DEVICES_KEY = 'samsungtv_known_devices'

SUPPORT_SAMSUNGTV = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \
    SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | \
    SUPPORT_NEXT_TRACK | SUPPORT_TURN_OFF | SUPPORT_PLAY | SUPPORT_PLAY_MEDIA

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
    vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Samsung TV platform."""
    known_devices = hass.data.get(KNOWN_DEVICES_KEY)
    if known_devices is None:
        known_devices = set()
        hass.data[KNOWN_DEVICES_KEY] = known_devices

    uuid = None
    # Is this a manual configuration?
    if config.get(CONF_HOST) is not None:
        host = config.get(CONF_HOST)
        port = config.get(CONF_PORT)
        name = config.get(CONF_NAME)
        mac = config.get(CONF_MAC)
        timeout = config.get(CONF_TIMEOUT)
    elif discovery_info is not None:
        tv_name = discovery_info.get('name')
        model = discovery_info.get('model_name')
        host = discovery_info.get('host')
        name = "{} ({})".format(tv_name, model)
        port = DEFAULT_PORT
        timeout = DEFAULT_TIMEOUT
        mac = None
        udn = discovery_info.get('udn')
        if udn and udn.startswith('uuid:'):
            uuid = udn[len('uuid:'):]
    else:
        _LOGGER.warning("Cannot determine device")
        return

    # Only add a device once, so discovered devices do not override manual
    # config.
    ip_addr = socket.gethostbyname(host)
    if ip_addr not in known_devices:
        known_devices.add(ip_addr)
        add_entities([SamsungTVDevice(host, port, name, timeout, mac, uuid)])
        _LOGGER.info("Samsung TV %s:%d added as '%s'", host, port, name)
    else:
        _LOGGER.info("Ignoring duplicate Samsung TV %s:%d", host, port)


class SamsungTVDevice(MediaPlayerDevice):
    """Representation of a Samsung TV."""

    def __init__(self, host, port, name, timeout, mac, uuid):
        """Initialize the Samsung device."""
        from samsungctl import exceptions
        from samsungctl import Remote
        import wakeonlan
        # Save a reference to the imported classes
        self._exceptions_class = exceptions
        self._remote_class = Remote
        self._name = name
        self._mac = mac
        self._uuid = uuid
        self._wol = wakeonlan
        # Assume that the TV is not muted
        self._muted = False
        # Assume that the TV is in Play mode
        self._playing = True
        self._state = None
        self._remote = None
        # Mark the end of a shutdown command (need to wait 15 seconds before
        # sending the next command to avoid turning the TV back ON).
        self._end_of_power_off = None
        # Generate a configuration for the Samsung library
        self._config = {
            'name': 'HomeAssistant',
            'description': name,
            'id': 'ha.component.samsung',
            'port': port,
            'host': host,
            'timeout': timeout,
        }

        if self._config['port'] == 8001:
            self._config['method'] = 'websocket'
        else:
            self._config['method'] = 'legacy'

    def update(self):
        """Update state of device."""
        self.send_key("KEY")

    def get_remote(self):
        """Create or return a remote control instance."""
        if self._remote is None:
            # We need to create a new instance to reconnect.
            self._remote = self._remote_class(self._config)

        return self._remote

    def send_key(self, key):
        """Send a key to the tv and handles exceptions."""
        if self._power_off_in_progress() \
                and key not in ('KEY_POWER', 'KEY_POWEROFF'):
            _LOGGER.info("TV is powering off, not sending command: %s", key)
            return
        try:
            # recreate connection if connection was dead
            retry_count = 1
            for _ in range(retry_count + 1):
                try:
                    self.get_remote().control(key)
                    break
                except (self._exceptions_class.ConnectionClosed,
                        BrokenPipeError):
                    # BrokenPipe can occur when the commands is sent to fast
                    self._remote = None
            self._state = None
        except (self._exceptions_class.UnhandledResponse,
                self._exceptions_class.AccessDenied):
            # We got a response so it's on.
            self._state = None
            self._remote = None
            _LOGGER.debug("Failed sending command %s", key, exc_info=True)
            return
        except OSError:
            self._state = STATE_OFF
            self._remote = None
        if self._power_off_in_progress():
            self._state = STATE_OFF

    def _power_off_in_progress(self):
        return self._end_of_power_off is not None and \
               self._end_of_power_off > dt_util.utcnow()

    @property
    def unique_id(self) -> str:
        """Return the unique ID of the device."""
        return self._uuid

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def is_volume_muted(self):
        """Boolean if volume is currently muted."""
        return self._muted

    @property
    def supported_features(self):
        """Flag media player features that are supported."""
        if self._mac:
            return SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON
        return SUPPORT_SAMSUNGTV

    def turn_off(self):
        """Turn off media player."""
        self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)

        if self._config['method'] == 'websocket':
            self.send_key('KEY_POWER')
        else:
            self.send_key('KEY_POWEROFF')
        # Force closing of remote session to provide instant UI feedback
        try:
            self.get_remote().close()
            self._remote = None
        except OSError:
            _LOGGER.debug("Could not establish connection.")

    def volume_up(self):
        """Volume up the media player."""
        self.send_key('KEY_VOLUP')

    def volume_down(self):
        """Volume down media player."""
        self.send_key('KEY_VOLDOWN')

    def mute_volume(self, mute):
        """Send mute command."""
        self.send_key('KEY_MUTE')

    def media_play_pause(self):
        """Simulate play pause media player."""
        if self._playing:
            self.media_pause()
        else:
            self.media_play()

    def media_play(self):
        """Send play command."""
        self._playing = True
        self.send_key('KEY_PLAY')

    def media_pause(self):
        """Send media pause command to media player."""
        self._playing = False
        self.send_key('KEY_PAUSE')

    def media_next_track(self):
        """Send next track command."""
        self.send_key('KEY_FF')

    def media_previous_track(self):
        """Send the previous track command."""
        self.send_key('KEY_REWIND')

    async def async_play_media(self, media_type, media_id, **kwargs):
        """Support changing a channel."""
        if media_type != MEDIA_TYPE_CHANNEL:
            _LOGGER.error('Unsupported media type')
            return

        # media_id should only be a channel number
        try:
            cv.positive_int(media_id)
        except vol.Invalid:
            _LOGGER.error('Media ID must be positive integer')
            return

        for digit in media_id:
            await self.hass.async_add_job(self.send_key, 'KEY_' + digit)
            await asyncio.sleep(KEY_PRESS_TIMEOUT, self.hass.loop)

    def turn_on(self):
        """Turn the media player on."""
        if self._mac:
            self._wol.send_magic_packet(self._mac)
        else:
            self.send_key('KEY_POWERON')

it works if deactivated, and without warning messages

I hope it helps you to do your job

Regards

@LeidenSpain You are not using the right version. You still have the requirements from old code. Please carefully use the new code and update the imports.

@LeidenSpain You are not using the right version. You still have the requirements from old code. Please carefully use the new code and update the imports.

I know I'm using an old version adapted to the new dependencies, but it's the best way I've found.
It does not deactivate after a while.

If I use the new option, after a few seconds it does not give me the option to pause.

ops
I just re-verified the version of samsungctl, and without doing anything has changed version

samsungctl --version
samsungctl 0.7.1

I've just updated to the new version. I'm running HA 0.88.1 in a Venv.

Have verified via pip list that samsungctl 0.8.64b0 is installed.

Upon HA starting up, I get a notification to configure my UA60H6400 for a name, description, and mac address. I save that info and then nothing. There are no errors in the logs. Just nothing happens after the first notification.

@LeidenSpain Yes, that is exactly why I asked you to use the new code. Please don't add other complications to the mix.

OK, aorry
Only for the purpose of providing all possible information.

Why will the samsungctl version change itself?

because that is what you specified in your samsungtv.py

because that is what you specified in your samsungtv.py

aahhhhhhhhhhhh
thanks

I put it all original again

Now:

samsungctl --version
samsungctl 0.8.64b

new samsungtv.py (from the first post).

REQUIREMENTS = [
     'https://github.com/kdschlosser/'
     'samsungctl/archive/develop.zip#samsungctl==0.8.64b'

Deleted de __pycache__ folder

and....

Thu Feb 28 2019 00:15:52 GMT+0100 (hora estándar de Europa central)
Error loading custom_components.samsungtv.media_player. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 147, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv/media_player.py", line 17, in <module>
    from homeassistant.components.media_player import (
ImportError: cannot import name 'MEDIA_TYPE_CHANNEL'

and again the old samsungctl version:

samsungctl --version
samsungctl 0.7.1

So, I tried the updated code. I sometimes see the config prompt in the configurator and when I use the config the entity gets added (but it shows incorrect state). Also, when I restart HA, the entity does not appear again and nor does the configuration screen appear again. Unfortunately, nothing in the logs.

Also, I'm not seeing any config file created.

Ok....so after some time, the configurator appeared again and I added the tv one more time. I was able to turn on the TV from the HA entity, but the status was not right. Here are some logs

019-02-27 20:27:45 DEBUG (Thread-3) [custom_components.samsungtv.media_player] name = Samsung TV Connector [homeassistant]
description = homeassistant
host = 192.168.2.252
port = 8001
id = b0d2364-0507-428c-8c7f-8XYXYXY147
method = websocket
timeout = 0
token = None
upnp_locations = http://192.168.2.252:9197/dmr, http://192.168.2.252:7678/nservice/, http://192.168.2.252:9110/ip_control
paired = False
mac = 64:1c:XY:XY:c7:33
model = UN75NU8000
app_id = None
uuid = 937afcea-106a-4fa1-8770-1XYZXYZ2d
display_name = None

2019-02-27 20:30:15 DEBUG (SyncWorker_4) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:30:26 DEBUG (SyncWorker_1) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:30:37 DEBUG (SyncWorker_9) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:30:45 DEBUG (Thread-7) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power on process started
2019-02-27 20:30:45 DEBUG (SyncWorker_15) [custom_components.samsungtv.media_player] UN75NU8000 TV: Powering On
2019-02-27 20:30:48 DEBUG (SyncWorker_11) [custom_components.samsungtv.media_player] UN75NU8000 TV: Powering On
2019-02-27 20:30:59 DEBUG (SyncWorker_0) [custom_components.samsungtv.media_player] UN75NU8000 TV: Powering On
2019-02-27 20:31:10 DEBUG (SyncWorker_16) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:31:21 DEBUG (SyncWorker_2) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:31:30 DEBUG (Thread-8) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power on process started
2019-02-27 20:31:30 DEBUG (SyncWorker_13) [custom_components.samsungtv.media_player] UN75NU8000 TV: Powering On
2019-02-27 20:31:32 DEBUG (SyncWorker_3) [custom_components.samsungtv.media_player] UN75NU8000 TV: Powering On
2019-02-27 20:31:43 DEBUG (SyncWorker_8) [custom_components.samsungtv.media_player] UN75NU8000 TV: Powering On
2019-02-27 20:31:53 DEBUG (SyncWorker_12) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:32:04 DEBUG (SyncWorker_5) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:32:15 DEBUG (SyncWorker_3) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off
2019-02-27 20:32:26 DEBUG (SyncWorker_4) [custom_components.samsungtv.media_player] UN75NU8000 TV: Power is Off

OK I have not updated anything yet. so continuing to mess around with the one that is posted is not going to get you anywhere. It does not work correctly. II know this. I have been working on it. There are still problems with samsungctl. I need to get those all cleaned up and everything running properly before I am going to do anything with getting it to run in hass. I am sorry but I am not going to be able to get the code updated today. Family business took most of my day. so I was not able to get the last couple of things fixed. I only have a 2-3 hour window for testing so I do not get to work on it all that much. The people that do the testing for me are an 8 hour time difference. so it makes it a bit challenging.

Don't worry, the family is the first

@kdschlosser thanks for being so responsive on here despite your family business :)

Hey Guys, hoping someone can assist here. I am not able to get this working. Below is what I've attempted to get this to work.

Currently running Hassio 0.88.2 (recently upgraded from 0.87.1)

First, I tried deleting everything that had to do with samsungctl.

  • samsung_tv from config
  • samsung file in bin folder in deps
  • both samsung folders in lib folder in deps

Restart Hassio - Nothing

Did some more digging by checking the version that was installed:

  • Putty'd into pi and ran docker exec -it
    /bin/bash
  • pip list shows samsungctl version 0.7.1
  • Run pip uninstall samsungctl - completes
    successfully
  • install version from kdschlosser's GitHub
    (0.8.64b, actually installs .65) - successful
  • Restart Hassio - nothing
  • log back in to container after restart and
    check version, back to 0.7.1

I have also updated the custom component due to the latest changes....custom_component/samsungctl/media_player.py.

Have also updated the constraints due to changes in 0.88

from homeassistant.components.media_player import (
PLATFORM_SCHEMA, MediaPlayerDevice)
from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_PLAY_MEDIA,
SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_VOLUME_SET,
SUPPORT_SELECT_SOURCE, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_STEP, MEDIA_TYPE_CHANNEL)

Log shows error.....assuming this is because the version is not correct

ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform samsungtv
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
return fut.result()
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/media_player.py", line 137, in setup_platform
auto_discover.start()
File "/config/deps/lib/python3.7/site-packages/samsungctl/upnp/discover.py", line 207, in start
for adapter_ip in adapter_addresses.get_adapter_ips():
File "/config/deps/lib/python3.7/site-packages/samsungctl/upnp/UPNP_Device/adapter_addresses.py", line 215, in get_adapter_ips
ip = sockaddr_to_ip(addr[0].ifa_addr)
File "/config/deps/lib/python3.7/site-packages/samsungctl/upnp/UPNP_Device/adapter_addresses.py", line 66, in sockaddr_to_ip
byte_ip = list(struct.unpack(b'!B', b)[0] for b in ippacked)
File "/config/deps/lib/python3.7/site-packages/samsungctl/upnp/UPNP_Device/adapter_addresses.py", line 66, in
byte_ip = list(struct.unpack(b'!B', b)[0] for b in ippacked)
TypeError: a bytes-like object is required, not 'int'

Stuck at the moment, hoping for some guidance.

Thanks

@djkmod83 The code is not ready yet. Just follow this thread and wait for an update from @kdschlosser.

@arsaboo thanks I just read a couple posts up from @kdschlosser and not sure how I missed this

"OK I have not updated anything yet. so continuing to mess around with the one that is posted is not going to get you anywhere"

I'll standby

So what was the resolution to this since it was closed?

someone else can integrate samsungctl into hass. I do not have the time nor the want to do it.

@kdschlosser is the samsungctl library developer. He doesn't know the Home Assistant code. It is very annoying to understand all the code of a system that you have not developed, and he does not have to do it. We must understand that.

He also asked for help from a Home Assistant developer to help him integrate his code, but no one volunteered.

However, he continues to improve the samsungctl library to support ALL TV models, and some of us are helping him. This is the first step. Without the samsungctl library, nothing is possible in HA with Samsung TVs.

If there is a volunteer who wants to help us to debug samsungctl outside the Home Assistant environment, he just needs basic knowledge of Python, and have a TV model that tells us @kdschlosser

The first step is to complete the samsungctl library. Then we will see who can help us integrating it into Home Assistant. Some developer may see the samsungctl commit and decide to merge it in Home Assistant ...

But of course, the first thing is to complete samsungctl. Thanks for everything you are doing @kdschlosser :-)

I have an MU6300 if I can help you! I'd really like to have near full control of it from HA!

This is exactly what I was afraid of. In trying to get everything working for ALL TVs, we are stuck with nothing working for anything. We should focus on getting the most basic component ready and then add features. I hope someone can pick this up. Thanks @kdschlosser for all your efforts.

This is exactly what I was afraid of.

Yep. Me too. I really hope something can come out of this. I guess it's the waiting game now.

This is exactly what I was afraid of. In trying to get everything working for ALL TVs, we are stuck with nothing working for anything. We should focus on getting the most basic component ready and then add features. I hope someone can pick this up. Thanks @kdschlosser for all your efforts.

Totally agree! But where are we waiting on now? The library is working as far I can see, it only has to be integrated into HA. I have extended Python knowledge and a Samsung TV, but no knowledge about HA infra. Maybe @kdschlosser can confirm the libary is working? Then we can develop the integration...

Thanks @Answer-1. Let's wait for @kdschlosser to tell us if he needs to test with the MU6300 model.

@Onandon11 the library is not complete. It needs to be refined with all models. Hence, we need testers

I think you are a little impatient. There are many models of Samsung TV, and ideally it would work in all.

Anyway, while @kdschlosser finishes fixing the library, you can investigate who could lead the integration in HA. I have already written a couple of emails looking for help without success.

@arsaboo I saw you have committed some code in the samsungtv component of Home Assistant. Would you be able to help in the integration with HA when samsungctl is ready?

ok I will tell you where I am at with the library. I need someone that uses the tuner on the TV. a TV that is 2015 or older. I am able to provide a channel lineup with channel names i simply need to know the format of the file.

if you go to this URL in your browser on your PC with the TV on and replacing YOUR_TV_IP with the IP of your TV.

http://YOUR_TV_IP:9090/BinaryBlob/3/ChannelList.dat

save the file and zip it up and attach it to an issue in the samsungctl repo.

that is the only thing left for the UPNP end of things.
The library is 100% working for legacy TV's
I did some pretty serious housekeeping on the code. and I cleaned up a lot of things and improved the overall performance of the library.
The TV discovery is 100% working now.
The power state is also working
I am in the process of getting the encrypted websocket back into running order. I removed a massive amount of code that was not needed. and removed multiple creations of the aes encryption object that gets used when connecting to the TV. I moved all of thee code that is specific to the TV control into the remote classes. you can see the large code update i did here.

https://github.com/kdschlosser/samsungctl/commit/b52b2ae13a3c418d9ed1b4e7d43187781076fa3e

I have not tested the websocket or websocket ssl portion of the library. I have not had someone that has one of these TV's offer to help in the debugging

I created a script that will test every single component of the library so helping to test only requires you to install python 2.7 and python 3.5+ install a few modules using pip in both python installations. and then run the test program. then send me the data. everything gets writen to a series of files and from those files I am able to fix issues and i can fix them really quickly.

What I had wanted to do was to add all of the available functionality of samsungctl to hass. and not just volume up and down and power. I have asked several times for guidance/help doing that portion of it and have not heard a peep from anyone. because of how hass is coded an IDE is pretty much useless in the help department. and I simply do not have the time to learn by trial and error. I do have things that require my attention other then a PC. Most of the users here are on the opposite side of the planet from me. But it seems as tho I am the one that is staying up all night working on this thing. Frankly I am getting burnt and I am falling behind with other tasks.

The library works for my TV. so anything i do now with the library is not to my benefit. it is for yours. I should not be the only one that is sacrificing in order to provide you with a way to control your TV. any of the people that have run the test program has seen the amount of data that i have to shuffle through in order to get things working. and being tired does not help.

And we are very grateful for your effort @kdschlosser.

Therefore, the most important thing is that you do not feel pressured. Work on the component when you have time and feel like it, and ignore all the pressures. I think nobody here does it, but sometimes it can seem like it.

There is no hurry. Currently Samsung TVs do not work properly in Home Assistant, and everything we get, however little, is an advance. We have already come a long way, and I know that eventually we will achieve it, but we have life, family, and that is the first thing. Who does not understand it, has a problem.

@kdschlosser I will try to provide you the file of the channels list you have requested. My 2014 TV should be able to provide it.

On the other hand, @Answer-1 has a MU6300 and he offered his help. I think this one uses websocket. If I'm right and you want, I can help him prepare the Python environment and get data from his TV :-)

@sermayoral, yep, my MU6300 uses ssl websocket. The tv was mostly working in HA before the 1250 Samsung firmware update. There was a fix to adapt the ssl websocket, which made it work again (mostly, on, off, mute, volume) but the tv got another firmware update and stopped working again.

I will gladly help if you need info from my tv. I have a PI2 laying around so I could get it running again and test what you need me to!

Thanks @Answer-1

Please join to slack group using this invitation: https://join.slack.com/t/samsungtvcontrol/shared_invite/enQtNTUzMDQ4ODY1MDk0LTA0Yjk3OTIwZWM0ODdmODFiMGEyNzg1OTBlZWI2YzEyYzNiMThiOTg0MDQxNDJiMjRlN2RiMDYzY2UzNjQwNTg

After that, talk to me in order to preparing your system. You need a PC connected in the same LAN than the TV. When you are ready. You only need to execute a test program and report results :-)

@kdschlosser thank you for the hard work you put in attempting to get this working. My last comment was just wondering what the status was.

I can also try and help swap out the current implementation once it gets ready for prime time. I've at least contributed to the Samsung TV component in the past (tiny contribution of channel changing) but am willing to help out where I can, when I can! @kdschlosser I've got a websocket tv if it helps. Let me know what I can do!

For Athom Homey, somebody managed to make a working app. Possibly this could give some clues for the Home assistant module.

https://github.com/balmli/com.samsung.smart/tree/cd455cbb5cb27988e7e32e2489cf604e7135843d

@sermayoral and @kdschlosser do you guys still need testers? I have take a version of @kdschlosser library and have it running via a custom component in my home assistant so may be able to help some if desired.

@tmonck could you make a quick howto for that?

@tmonck Will be great if you can share the custom component. We can then improve upon it.

@tmonck

I m assuming you are familiar with python. if so i could always use a hand. this is where we are testing the software at

https://github.com/kdschlosser/samsungctl/issues/106. it's pretty simple. download the develop branch. and then run the RUN_ME.py file.

@Gamelauncher The quick howto is:

  1. Copy this directory https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/samsungtv into your custom components directory. (This is just the default samsungtv component.
  2. Inside the media_player.py file add the following code to the init function in the SamsungTVDevice class:
    from custom_components.samsungctl import exceptions from custom_components.samsungctl import Remote
  3. Change 8001 to 8002 for the port
  4. Clone the samsungctl repo that is being developed by @kdschlosser.
  5. Copy that entire repo in to a samsungctl directory under custom_components directory.

@arsaboo If I had made major modifications I would share but as you can see from my steps above I am just using the existing component with no fancy addons. I am excited to attempt to help integrate some of the new features you guys have been adding.

@kdschlosser I will jump over to that issue and see where I can assist.

@tmonck I see the following error

Log Details (ERROR)
Wed Mar 27 2019 18:44:12 GMT-0400 (Eastern Daylight Time)
Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  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/media_player.py", line 85, in setup_platform
    add_entities([SamsungTVDevice(host, port, name, timeout, mac, uuid)])
  File "/config/custom_components/samsungtv/media_player.py", line 96, in __init__
    from custom_components.samsungctl import exceptions
  File "/config/custom_components/samsungctl/__init__.py", line 25, in <module>
    from .config import Config # NOQA
  File "/config/custom_components/samsungctl/config.py", line 8, in <module>
    from . import wake_on_lan
  File "/config/custom_components/samsungctl/wake_on_lan.py", line 17, in <module>
    from .upnp.UPNP_Device import adapter_addresses
  File "/config/custom_components/samsungctl/upnp/__init__.py", line 7, in <module>
    from .discover import discover
  File "/config/custom_components/samsungctl/upnp/discover.py", line 12, in <module>
    from ..config import Config
ImportError: cannot import name 'Config' from 'custom_components.samsungctl.config' (/config/custom_components/samsungctl/config.py)

Nearly working ! Mute, Volume works but power doesn't.
Also this is is my log:

Log Details (ERROR)
Fri Mar 29 2019 17:28:12 GMT+0000 (Greenwich Mean Time)
Unknown Auth Failure: 
name = HomeAssistant
description = TV
host = 192.168.1.135
port = 8002
id = ha.component.samsung
method = websocket
timeout = 1
token = None
upnp_locations = None
paired = False
mac = None
model = None
app_id = None
uuid = None
display_name = None
// ****** CEC MUST REMAIN AT THE END OF THE FILE ******
cec:
//  name = SamsungTVCEC
//  port = RPI
//  types = 4,
//  power_off = 0
//  power_standby = 0
//  wake_avr = 0
//  keypress_combo = 113
//  keypress_combo_timeout = 50
//  keypress_repeat = 200
//  keypress_release_delay = 0
//  keypress_double_tap = 100
//  hdmi_port = 1
//  avr_audio = False
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 122, in handle_call_service
    connection.context(msg))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1138, in async_call
    self._execute_service(handler, service_call))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1160, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 314, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 328, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py", line 734, in async_volume_down
    await self.hass.async_add_job(self.volume_down)
  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/media_player.py", line 228, in volume_down
    self.send_key('KEY_VOLDOWN')
  File "/config/custom_components/samsungtv/media_player.py", line 156, in send_key
    self.get_remote().control(key)
  File "/config/custom_components/samsungtv/media_player.py", line 141, in get_remote
    self._remote = self._remote_class(self._config)
  File "/config/custom_components/samsungctl/remote.py", line 32, in __call__
    remote = RemoteWebsocket(config)
  File "/config/custom_components/samsungctl/utils.py", line 29, in wrapper
    return func(*args, **kwargs)
  File "/config/custom_components/samsungctl/remote_websocket.py", line 34, in __init__
    websocket_base.WebSocketBase.__init__(self, config)
  File "/config/custom_components/samsungctl/utils.py", line 29, in wrapper
    return func(*args, **kwargs)
  File "/config/custom_components/samsungctl/websocket_base.py", line 51, in __init__
    self.open()
  File "/config/custom_components/samsungctl/utils.py", line 29, in wrapper
    return func(*args, **kwargs)
  File "/config/custom_components/samsungctl/remote_websocket.py", line 213, in open
    raise RuntimeError('Unknown Auth Failure: \n' + str(self.config))
RuntimeError: Unknown Auth Failure: 
name = HomeAssistant
description = TV
host = 192.168.1.135
port = 8002
id = ha.component.samsung
method = websocket
timeout = 1
token = None
upnp_locations = None
paired = False
mac = None
model = None
app_id = None
uuid = None
display_name = None
// ****** CEC MUST REMAIN AT THE END OF THE FILE ******
cec:
//  name = SamsungTVCEC
//  port = RPI
//  types = 4,
//  power_off = 0
//  power_standby = 0
//  wake_avr = 0
//  keypress_combo = 113
//  keypress_combo_timeout = 50
//  keypress_repeat = 200
//  keypress_release_delay = 0
//  keypress_double_tap = 100
//  hdmi_port = 1
//  avr_audio = False

   from custom_components.samsungctl import exceptions
   from custom_components.samsungctl import Remote

Thanks for sharing @tmonck, could you please point to le line where i should input this code.

Thank you.

   from custom_components.samsungctl import exceptions
   from custom_components.samsungctl import Remote

Thanks for sharing @tmonck, could you please point to le line where i should input this code.

Thank you.

Line 89, 90.

Where did you change the port to 8002? In the copied over samsungtv code and if yes where or config?
When you say copy over the whole component of kdschlosser, you mean https://github.com/kdschlosser/samsungctl/tree/develop/samsungctl or THE WHOLE ONE?

According to the "Line 89,90" I guess we have to REPLACE the lines, right?

First of all, thank you for the hard work you put into this project. I am trying to run this in hass.io. everything seems to run fine except it won't discover my tv. When i look at the logs i see that the autodiscovery part only scans the known hosts from the docker container. But it never reaches the callback function defined at auto_discover.register_callback(callback). Does anybody have a working version of this on their hass.io instances? My Samsung TV is a model": "18_KANTM2_QTV", "modelName": "QE55Q6FNA", "name": "[TV] Samsung Q6 Series (55)",

Where did you change the port to 8002? In the copied over samsungtv code and if yes where or config?
When you say copy over the whole component of kdschlosser, you mean https://github.com/kdschlosser/samsungctl/tree/develop/samsungctl or THE WHOLE ONE?

According to the "Line 89,90" I guess we have to REPLACE the lines, right?

You may refer to my recent patch for changes needed: https://github.com/home-assistant/home-assistant/pull/24716/commits/165583696dc34f999251e6d2e074fab67050e910

Hey guys!!!
First of all thanks for all the work on this component and in this whole thread helping other people!!!

After struggling for a few days, i finally managed to find where to put the samsungtv.py code from the first post. On my instalation, (Raspbian on Rasbperry pi 3) the file was located at: /srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/media_player

Ok, first step was OK. After changing the samsungtv.py for the one on the first post, I added the following lines to my configuration.yaml:

media_player:
  - platform: samsungtv

Then I restarted Home Assistant. This shows up in the end of the log:

Jun 27 22:29:10 raspberrypi2 hass[539]: 2019-06-27 22:29:10 INFO (MainThread) [homeassistant.components.discovery] Unknown service discovered: dlna_dmr {'port': 9197, 'host': '192.168.0.31', 'model_number': 'AllShare1.0', 'serial': 'Y2V**********7E', 'udn': 'uuid:b******5-c**8-4**a-9**1-b**********e', 'name': '[TV] Samsung 7 Series (50)', 'model_name': 'UN50NU7100', 'manufacturer': 'Samsung Electronics', 'ssdp_description': 'http://192.168.0.31:9197/dmr', 'upnp_device_type': 'urn:schemas-upnp-org:device:MediaRenderer:1'}

(I changed some of the characters to "*" because I don't know what those fields are and if its ok to share with everyone).

After HA starts, nothing happens. No "New Device Discovered" panel shows up. The media_player doesn't appear on the "State" page either.
The "samsung_tv" folder is created on the homeassistant directory. But it's empty.

As showed in the logs, the TV model is UN50NU7100.

Any idea of what happened or what am I doing wrong?
Any other information I need to provide?

Thanks

@kdschlosser thank for your work! I got it working for my TV (Samsung Frame 2018) the only thing for the power off I need a longpress on the power button otherwise the TV will go to "Art Modus".

Any thoughts how to make a long press power off function?

Small edit, I found how they did it for HomeBridge with .JS:

await this.command(this.device.storage.frametv ? 'KEY_POWER*3s' : 'KEY_POWER');

@kdschlosser thank for your work! I got it working for my TV (Samsung Frame 2018) the only thing for the power off I need a longpress on the power button otherwise the TV will go to "Art Modus".

Any thoughts how to make a long press power off function?

Small edit, I found how they did it for HomeBridge with .JS:

await this.command(this.device.storage.frametv ? 'KEY_POWER*3s' : 'KEY_POWER');

How?

@kdschlosser thank for your work! I got it working for my TV (Samsung Frame 2018) the only thing for the power off I need a longpress on the power button otherwise the TV will go to "Art Modus".
Any thoughts how to make a long press power off function?
Small edit, I found how they did it for HomeBridge with .JS:
await this.command(this.device.storage.frametv ? 'KEY_POWER*3s' : 'KEY_POWER');

How?

But I don't have the experience to change this from JavaScript to Python:

https://github.com/tavicu/homebridge-samsung-tizen/blob/255bf9ecd31a1e60bb8cf9ea67d715330b40146d/lib/remote.js

Thanks, I thought you had the component working.

on hassio all I get is this even if I manually put samsungctl folder there.
I'm trying to get this working on a 55JS8500

Fri Jul 12 2019 12:43:02 GMT-0500 (Central Daylight Time)
Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  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/media_player.py", line 102, in setup_platform
    from samsungctl.upnp.discover import auto_discover
ModuleNotFoundError: No module named 'samsungctl.upnp'

on hassio all I get is this even if I manually put samsungctl folder there.
I'm trying to get this working on a 55JS8500

Fri Jul 12 2019 12:43:02 GMT-0500 (Central Daylight Time)
Error while setting up platform samsungtv
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  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/media_player.py", line 102, in setup_platform
    from samsungctl.upnp.discover import auto_discover
ModuleNotFoundError: No module named 'samsungctl.upnp'

I get the ModuleNotFoundError: No module named 'samsungctl.upnp' error too

Could someone please provide up to date installation instructions? They're very confusing from earlier, i.e.

  • are we replacing the lines
        from samsungctl import exceptions
        from samsungctl import Remote

with

   from custom_components.samsungctl import exceptions
   from custom_components.samsungctl import Remote

or overwriting?

  • does the port need changing somewhere still?
  • do we need to run RUN_ME.py?
  • do we need to make changes in samsungctl.conf under homeassistant/custom_components/samsungctl?
  • do we copy https://github.com/kdschlosser/samsungctl/tree/develop/samsungctl or the entire repo (https://github.com/kdschlosser/samsungctl) into /custom_components.

Thank you.

Okay, think I've got it half figured out

  1. Create a folder /homeassistant/custom_components/samsungtv
  2. Copy the files from https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/samsungtv into /homeassistant/custom_components/samsungtv
  3. Create a folder /homeassistant/custom_components/samsungctl
  4. Copy the files from https://github.com/kdschlosser/samsungctl/tree/develop/samsungctl into /homeassistant/custom_components/samsungctl
  5. Add
 media_player:
 - platform: samsungtv
   host: <whatever> (not sure if host is needed but it wouldn't accept the config for me without it)

Think this is everything. It now recognises the power state of my TV (again) but remote control does not work.

Edit: nah, it's not working at all. Shows On constantly.

I brought a rm mini 3. WiFi ir, works perfect for 2015 series

I gave up on trying to get Samsung TV working with this and used a nodeMCU with ir transmitter running esphome and a power monitoring plug to detect when it is switched on.

Port 8000 gives me accurate on/off state

I'm looking in /srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/media_player folder like @BrunoZumba but there is no samsungtv.py file in that folder for me.

Running Hassbian v0.97.2

There is indeed a component samsungtv at /srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/samsungtv with media_player.py inside. I tried to put the code from the first post from @kdschlosser but obviously didn't work: Got Failed to get platform media_player.samsungtv in the log.

What is the last direction to follow to make samsungctl to work with Home Assistant ?

Thanks.

I gave up on trying to get Samsung TV working with this and used a nodeMCU with ir transmitter running esphome and a power monitoring plug to detect when it is switched on.

Same here. Using Broadlink to learn the remote and replay them.

I gave up on trying to get Samsung TV working with this and used a nodeMCU with ir transmitter running esphome and a power monitoring plug to detect when it is switched on.

I gave up on trying to get Samsung TV working with this and used a nodeMCU with ir transmitter running esphome and a power monitoring plug to detect when it is switched on.

Same here. Using Broadlink to learn the remote and replay them.

Hey guys, what power monitoring plug did you use to do this?
Thanks!

I used a Popp zwave socket, don't think they are made any more but any zwave or ZigBee socket with power monitoring capabilities should work.

So.. should I try this solution (component) or not?
Currently on HA version 0.99.2 my 2 Samsung TV are not showing status at all.. Using in-build solution..

My TV:
UE43MU6172U
UE40H6200AK

After HA updates, I have decided to create a custom component, it is working on the latest version of HA 0.99.3, I have uploaded the code to:

https://github.com/roberodin/ha-samsungtv-custom

I hope it helps you.

Hello!
I use this fork https://github.com/xchwarze/ha-samsungtv-custom/releases in 2016+ tv
All TizenOS tv should work

Hi, I have uploaded the latest version 2.0.1 in HACS. If not working by default samsungctl protocol, try changing it to WS protocol for 2016+ TVs model…

https://github.com/roberodin/ha-samsungtv-custom

Wow! That's great!!

We can test the HACS version and debug it until it is perfect!!

Thanks guys. Great work.

@sermayoral Have you been able to make it work on an encrypted tv? Can you please help me with it?

Update to version 3.0.0 and try the new protocols:
-ws (fixed from @xchwarze)
-ctl_beta
-ctl_qled

https://github.com/roberodin/ha-samsungtv-custom

@pablolassalle I have not tested this addon yet, but it sounds great.

Anyway. What is your problem? What is your TV's model? Mine is H6400 of 2014.

@roberodin Do you know if ha-samsungtv-custom works with encrypted tvs like H6400?

@sermayoral my tv is a J5500 from 2015, my tv does require a pin for pairing. I think also your tv does require it. Problem is I have never that blue box on my tv asking for pairing with xxxx pin, which I should enter on my HOMEASSISTANT.
At the momment I am using a custom samsungtv I have found somewehere, but it only shows me if the TV is ON or OFF. I can´t control anything.

Awesome... i've been looking for a solution for months now. I can confirm that most things are working on the Q6 2019 samsung tv. Thanks a lot guys :)

@roberodin I'm also curious if this works on the 2014/2015 tv models (H and J).

Those used an encrypted connection, which I believe the original component on this git did support for a while.

I have H series TV. I tried multiple components and they never work as expected

@roberodin This is something incredible! I can control it. Thanks for this component.
Samsung 5 Series (32) (UE32M5500) 2017 TV.
Settings:
port: 8002
protocol: ws

@roberodin. Can you help us with encrypted TVs? For example 2014 H Series? @kdschlosser got it working. Those different is to introduce the pin when TV shows you...

Thank you!

.Hey Guys,
I've managed to get it working with the Samsung EU65NU8042 with respect to one "small" problem. TV asks me every 15 seconds if I allow the device to be connected. If I click yes, than, for 14 seconds it works, but after that, I need to agree once again... What the hell? :-)
My config is as follow:

- platform: samsungtv_custom
  host: 192.168.1.111 (correct one)
  port: 8002
  name: 'SamsungTv'

Any suggestions? Should I add MAC address, as I've seen in some configs that you have posted here?

Sorry for the beginners question:

My home assistant is installed as "hassio" on a raspberry pi. I think on this installation, there is no folder "/homeassistant/components/media_player/samsungtv.py". Right?

If so, is there any other alternative measure to get this fix from kdschlosser installed on hassio?

Many thanks!

@magicmatt007 this component doesn’t work anymore and no longer under development.

@magicmatt007 this component doesn’t work anymore and no longer under development.

Well that sucks.

Was this page helpful?
0 / 5 - 0 ratings