Git Product home page Git Product logo

ha-samsungtv-tizen's Introduction

hacs_badge

HomeAssistant - SamsungTV Tizen Component

This is a custom component to allow control of SamsungTV devices in HomeAssistant. Is a modified version of the built-in samsungtv with some extra features.
This plugin is only for 2016+ TVs model! (maybe all tizen family)

Development for this project relies solely on donations, so if you enjoy this component, please consider becoming a patron or donating to ensure it's continued survival.

Additional Features:

  • Ability to send keys using a native Home Assistant service
  • Ability to send chained key commands using a native Home Assistant service
  • Supports Assistant commands (Google Home, should work with Alexa too, but untested)
  • Extended volume control
  • Ability to customize source list at media player dropdown list including TV, HDMI sources, apps and specific tv channels
  • Cast video URLs to Samsung TV
  • Open browser pages on a Samsung TV
  • Supports Samsung Frame TVs
  • Connect to SmartThings Cloud API for additional features: see TV channel names, see which HDMI source is selected, more key codes to change input source
  • Display logos of TV channels (requires Smartthings enabled) and apps

N|Solid N|Solid N|Solid N|Solid

Installation

1. Easy Mode

Install via HACS.

2. Manual

Install it as you would do with any homeassistant custom component:

  1. Download custom_components folder.
  2. Copy the samsungtv_tizen directory within the custom_components directory of your homeassistant installation. The custom_components directory resides within your homeassistant configuration directory. Note: if the custom_components directory does not exist, you need to create it. After a correct installation, your configuration directory should look like the following.
    โ””โ”€โ”€ ...
    โ””โ”€โ”€ configuration.yaml
    โ””โ”€โ”€ custom_components
        โ””โ”€โ”€ samsungtv_tizen
            โ””โ”€โ”€ __init__.py
            โ””โ”€โ”€ media_player.py
            โ””โ”€โ”€ websockets.py
            โ””โ”€โ”€ shortcuts.py
            โ””โ”€โ”€ smartthings.py
            โ””โ”€โ”€ upnp.py
            โ””โ”€โ”€ exceptions.py
            โ””โ”€โ”€ manifest.json
    

Configuration

  1. Enable the component by editing the configuration.yaml file (within the config directory as well). Edit it by adding the following lines:

    # Example configuration.yaml entry
    media_player:
      - platform: samsungtv_tizen
        host: IP_ADDRESS
        mac: MAC_ADDRESS
    

    Note: This is the same as the configuration for the built-in Samsung Smart TV component.

    Custom configuration variables

    name:
    (string)(Optional)
    A name for your TV, this will also be used for the entity ID

    update_method:
    (string)(Optional)
    This change the ping method used for state update. Values: "ping", "websockets" and "smartthings"
    Default value: "ping"
    Example value: "websockets"

    update_custom_ping_url:
    (string)(Optional)
    Use custom endpoint to ping.
    Default value: PING TO 8001 ENDPOINT
    Example value: "http://192.168.1.77:9197/dmr"

    source_list:
    (json)(Optional)
    This contains the KEYS visible sources in the dropdown list in media player UI.
    Default value: '{"TV": "KEY_TV", "HDMI": "KEY_HDMI"}'
    You can also chain KEYS, example: '{"TV": "KEY_SOURCES+KEY_ENTER"}'
    And even add delays (in milliseconds) between sending KEYS, example:
    '{"TV": "KEY_SOURCES+500+KEY_ENTER"}'
    Resources: key codes / key patterns
    Warning: changing input source with voice commands only works if you set the device name in source_list as one of the whitelisted words that can be seen on this page (under "Mode Settings")

    app_list:
    (json)(Optional)
    This contains the APPS visible sources in the dropdown list in media player UI.
    Default value: AUTOGENERATED
    Example value: '{"Netflix": "11101200001", "YouTube": "111299001912", "Spotify": "3201606009684"}'
    Known lists of App IDs: List 1, List 2
    Note: For advanced use of this setting, read the app_list guide
    Note 2: Although this setting is optional, it is highly recommended (for best performance) to set it manually and not rely on the autogenerated list.

    channel_list:
    (json)(Optional)
    This contains the tv CHANNELS visible sources in the dropdown list in media player UI. Default format is '{"CHANNELNAME":"CHANNELNUMBER","CHANNELNAME":"CHANNELNUMBER"}' for standard channels in TV mode via antenna/coaxial input. Those that use external devices/network based players (e.g. DLNA) can define URLs instead to define the different channels they wish to have available. To guarantee performance keep the list small, recommended maximum 30 channels.
    Example value: '{"MTV": "14", "Eurosport": "20", "TLC": "http://url/"}'

    api_key:
    (string)(Optional)
    API Key for the SmartThings Cloud API, this is optional but adds better state handling on, off, channel name, hdmi source, and a few new keys: ST_TV, ST_HDMI1, ST_HDMI2, ST_HDMI3, etc. (see more at SmartThings Keys)
    How to get an API Key for SmartThings
    You must set both an api_key and device_id to enable the SmartThings Cloud API

    device_id:
    (string)(Optional)
    Although this is an optional value, it is mandatory if you've set a SmartThings API Key in order to identify your device in the API.
    How to get a device ID from SmartThings
    You must set both an api_key and device_id to enable the SmartThings Cloud API

    show_channel_number:
    (boolean)(Optional)
    If the SmartThings API is enabled (by settings "api_key" and "device_id"), then the TV Channel Names will show as media titles, by setting this to True the TV Channel Number will also be attached to the end of the media title. (when applicable)

    scan_app_http:
    (boolean)(Optional)
    This option is True by default. In some cases (if numerical IDs are used when setting app_list) HTTP polling will be used (1 request per app) to get the running app.
    This is a lengthy task that some may want to disable, you can do so by setting this option to False.
    For more information about how we get the running app, read the app_list guide.

    is_frame_tv:
    (boolean)(Optional)
    This option is False by default. The "Frame" model of Samsung TVs have an Art Mode feature, if this option is set to True the component will hold the power key for 3 seconds to turn off this TV model (instead of pressing normally which would go to Art Mode)

    show_logos:
    (string)(Optional)
    The background color and channel / service logo preference to use, example: "white-color" (background: white, logo: color). "none" to disable.
    Supported values: "none", "white-color", "dark-white", "blue-color", "blue-white", "darkblue-white", "transparent-color", "transparent-white"
    Default value: "white-color" (background: white, logo: color)
    Notice that your logo is missing or outdated? In case of a missing TV channel logo also make sure you have Smartthings enabled. This is required for the component to know the name of the TV channel. Check our guide here for updating the logo database this component is relying on.

    broadcast_address:
    (string)(Optional)
    Do not set this option if you do not know what it does, it can break turning your TV on.
    The ip address of the host to send the magic packet (for wakeonlan) to if the "mac" property is also set.
    Default value: "255.255.255.255"
    Example value: "192.168.1.255"

  2. Reboot Home Assistant

  3. Congrats! You're all set!

Usage

Known Supported Voice Commands

Google Home verified commands

  • Turn on SAMSUNG-TV-NAME-HERE (for some older TVs this only works if the TV is connected by LAN cable to the Network)
  • Turn off SAMSUNG-TV-NAME-HERE
  • Volume up on SAMSUNG-TV-NAME-HERE (increases volume by 1)
  • Volume down on SAMSUNG-TV-NAME-HERE (decreases volume by 1)
  • Set volume to 50 on SAMSUNG-TV-NAME-HERE (sets volume to 50 out of 100)
  • Mute SAMSUNG-TV-NAME-HERE (sets volume to 0)
  • Change input source to SOURCE-NAME-HERE on SAMSUNG-TV-NAME-HERE (can be any source name including an app, tv channel or HDMI source)

(if you find more supported voice commands, please create an issue so I can add them here)

Alexa support

Read our Alexa Guide

Cast to TV

service: media_player.play_media

{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "url",
  "media_content_id": "FILE_URL",
}

Replace FILE_URL with the url of your file.

Send Keys

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "send_key",
  "media_content_id": "KEY_CODE",
}

Note: Change "KEY_CODEKEY" by desired key_code. (also works with key chaining and SmartThings keys: ST_TV, ST_HDMI1, ST_HDMI2, ST_HDMI3, etc. / see more at SmartThings Keys)

Script example:

tv_channel_down:
  alias: Channel down
  sequence:
  - service: media_player.play_media
    data:
      entity_id: media_player.samsung_tv55
      media_content_id: KEY_CHDOWN
      media_content_type: "send_key"

Key Codes

To see the complete list of known keys, check this list

Key Chaining Patterns

Key chaining is also supported, which means a pattern of keys can be set by delimiting the keys with the "+" symbol, delays can also be set in milliseconds between the "+" symbols.

See the list of known Key Chaining Patterns

Open Browser Page

service: media_player.play_media
{
  "entity_id": "media_player.samsungtv",
  "media_content_type": "browser",
  "media_content_id": "https://www.google.com",
}

ha-samsungtv-tizen's People

Contributors

alejandrorivera avatar briktor avatar dtalens avatar giefca avatar jaruba avatar mcc05 avatar mikyjazz avatar ollo69 avatar pegatron89 avatar roberodin avatar ruttromp avatar sab44 avatar screwdgeh avatar xchwarze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ha-samsungtv-tizen's Issues

Error when restarting HA and tv is off

So I upgraded to 0.105.2 and i noticed a weird behavior. If I restart my HA and my TV is turned off it doesn't show as an entity and i'm getting the following error:
`custom_components/samsungtv_custom/samsungtvws/remote.py (ERROR)

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 424, in _async_add_entity await entity.async_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state attr = self.capability_attributes File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 774, in capability_attributes source_list = self.source_list File "/config/custom_components/samsungtv_custom/media_player.py", line 319, in source_list self._gen_installed_app_list() File "/config/custom_components/samsungtv_custom/media_player.py", line 229, in _gen_installed_app_list app_list = self._remote.app_list() File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 179, in app_list self._ws_send(payload) File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 93, in _ws_send self.open() File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 108, in open sslopt=sslopt File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 511, in create_connection websock.connect(url, **options) File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 220, in connect options.pop('socket', None)) File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect sock = _open_socket(addrinfo_list, options.sockopt, options.timeout) File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 186, in _open_socket raise error File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 170, in _open_socket sock.connect(address) socket.timeout: timed out

Now if i restart HA and my tv is turned on i'm getting this warning

helpers/entity.py (WARNING) Updating state for media_player.living_room_tv (<class 'custom_components.samsungtv_custom.media_player.SamsungTVDevice'>) took 0.616 seconds.

Anyone with similar problem?

Mimic STB POWER key?

Hello,

Loving your component. Everything is working fine and the smartthings addition really works great.

Iโ€™ve tried every possible key is the list, but I canโ€™t seem to find the right one to power toggle my KPN STB box.

My Samsung Q9F does have the option to do thing. Pressing the KEY_MORE two times, KEY_ENTER and then use the left option in below screenshot

5E689D13-65C3-4BB0-B961-CBF5A68458C7

Iโ€™d love to create an automation in Homeassistant to powertoggle the STB when the Samsung tv turns on. All other keys, like chup, chdown are correctly picked trough to the STB (wich is already great)

Get current channel number

First off great work! Plugin is working fine on both:

  • QE55Q6FNA
  • UE43RU7172

To make it complete besides the workaround for input switching, is there a way to get the current channel number?

TV showing as on, even when ping fails

The media player component shows the TV as ON/unavailable shortly after pressing the off button (Goes to off for 10-30 seconds and then the state changes back to on/unavailable, even through the TV is off and the ping is unreachable from my laptop)

I have a UA55NU7100 (2018)

My config:
- platform: samsungtv_custom host: 192.168.1.38 port: 8002 mac: XXX app_list: '{"Netflix": "11101200001", "YouTube": "111299001912", "Spotify": "3201606009684"}'

Media player showing "id"+ appname?

Issue

In some cases, when the app is started from the TV it has a id + app name in the mediaplayer:
image

When i open the card for more details, it's showing the correct source with the ID.
image

My configuration:
app_list: '{"YouTube": "111299001912", "Netflix": "11101200001", "Plex": "3201512006963", "Videoland": "3201810017074"}'

Did i do something wrong, or is this a bug?

System

arch x86_64
dev false
docker true
hassio true
os_name Linux
python_version 3.7.6
timezone Europe/Amsterdam
version 0.106.5
virtualenv false

Samsung TV Tizen v1.4.1

Does not request permission to access Samsung SmartTV J series

Good afternoon, I just can't beat the problem with the integration of Samsung SmartTV
UE48J6300

`http://192.168.169.9:8001/api/v2/
{
  "id": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
  "name": "[TV] Small room",
  "version": "2.0.25",
  "device": {
    "type": "Samsung SmartTV",
    "duid": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
    "model": "15_HAWKM_2D",
    "modelName": "UE48J6300",
    "description": "Samsung DTV RCR",
    "networkType": "wired",
    "ssid": "",
    "ip": "192.168.169.9",
    "firmwareVersion": "Unknown",
    "name": "[TV] Small room",
    "id": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
    "udn": "uuid:f09f5ade-7f97-460f-b79d-32e19bbc4d87",
    "resolution": "1920x1080",
    "countryCode": "RU",
    "msfVersion": "2.0.25",
    "smartHubAgreement": "true",
    "wifiMac": "f8:77:b8:df:06:e1",
    "developerMode": "0",
    "developerIP": ""
  },
  "type": "Samsung SmartTV",
  "uri": "http://192.168.169.9:8001/api/v2/"
}`

Nmap 7.80

`Starting Nmap 7.80 ( https://nmap.org ) at 2020-01-12 12:41 RTZ 4 (ceia)

NSE: Loaded 151 scripts for scanning.

NSE: Script Pre-scanning.

Initiating NSE at 12:41

Completed NSE at 12:41, 0.00s elapsed

Initiating NSE at 12:41

Completed NSE at 12:41, 0.00s elapsed

Initiating NSE at 12:41

Completed NSE at 12:41, 0.00s elapsed

Initiating ARP Ping Scan at 12:41

Scanning 192.168.169.9 [1 port]

Completed ARP Ping Scan at 12:41, 0.46s elapsed (1 total hosts)

Initiating Parallel DNS resolution of 1 host. at 12:41

Completed Parallel DNS resolution of 1 host. at 12:41, 0.00s elapsed

Initiating SYN Stealth Scan at 12:41

Scanning 192.168.169.9 [1000 ports]

Discovered open port 8080/tcp on 192.168.169.9

Discovered open port 7676/tcp on 192.168.169.9

Discovered open port 8002/tcp on 192.168.169.9

Discovered open port 9999/tcp on 192.168.169.9

Discovered open port 9090/tcp on 192.168.169.9

Discovered open port 8001/tcp on 192.168.169.9

Discovered open port 8000/tcp on 192.168.169.9

Completed SYN Stealth Scan at 12:41, 0.17s elapsed (1000 total ports)

Initiating Service scan at 12:41

Scanning 7 services on 192.168.169.9

Completed Service scan at 12:42, 44.83s elapsed (7 services on 1 host)

Initiating OS detection (try #1) against 192.168.169.9

NSE: Script scanning 192.168.169.9.

Initiating NSE at 12:42

Completed NSE at 12:42, 11.03s elapsed

Initiating NSE at 12:42

Completed NSE at 12:42, 0.38s elapsed

Initiating NSE at 12:42

Completed NSE at 12:42, 0.00s elapsed

Nmap scan report for 192.168.169.9

Host is up (0.0012s latency).

Not shown: 993 closed ports

PORT     STATE SERVICE  VERSION

7676/tcp open  upnp     Samsung AllShare upnpd 1.0 (UPnP 1.1)

8000/tcp open  http-alt

| fingerprint-strings: 

|   FourOhFourRequest, GetRequest, HTTPOptions: 

|     HTTP/1.1 500 Internal Server Error

|     Content-Type: text/plain

|     Date: Sun, 12 Jan 2020 07:41:59 GMT

|_    Connection: close

|_http-cors: GET POST PUT DELETE OPTIONS

|_http-favicon: Unknown favicon MD5: 33E3EA7FC9C08D2E72730482906A676C

| http-methods: 

|_  Supported Methods: GET HEAD POST OPTIONS

|_http-open-proxy: Proxy might be redirecting requests

|_http-title: Site doesn't have a title.

8001/tcp open  http     Tizen Multiscreen SDK httpd

|_http-cors: GET POST PUT DELETE

| http-methods: 

|_  Supported Methods: GET HEAD POST OPTIONS

|_http-title: 404 : Not Found

8002/tcp open  ssl/http Tizen Multiscreen SDK httpd

|_http-cors: POST PUT DELETE

| http-methods: 

|_  Supported Methods: GET HEAD POST OPTIONS

|_http-title: 404 : Not Found

| ssl-cert: Subject: commonName=SmartViewSDK/organizationName=SmartViewSDK/countryName=KR

| Subject Alternative Name: DNS:127.0.0.1, DNS:localhost

| Issuer: commonName=SmartViewSDK Root Ceritificate Authority/organizationName=SmartViewSDK/countryName=KR

| Public Key type: rsa

| Public Key bits: 2048

| Signature Algorithm: sha256WithRSAEncryption

| Not valid before: 2016-07-29T05:34:23

| Not valid after:  2036-07-29T05:34:23

| MD5:   189b 2634 fcca f1ef 31e1 7b7b 02ac c5bd

|_SHA-1: b15e 72c0 04b4 3825 651e e7a7 2b66 1856 305d e56b

|_ssl-date: TLS randomness does not represent time

| tls-nextprotoneg: 

|   http/1.1

|_  http/1.0

8080/tcp open  http     lighttpd

| http-methods: 

|_  Supported Methods: OPTIONS GET HEAD POST

|_http-server-header: WebServer

|_http-title: 404 - Not Found

9090/tcp open  http     Samsung UE55D7000 TV http config

|_http-favicon: Unknown favicon MD5: D41D8CD98F00B204E9800998ECF8427E

| http-methods: 

|_  Supported Methods: GET HEAD POST OPTIONS

|_http-title: Site doesn't have a title (application/octet-stream).

9999/tcp open  abyss?

1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :

SF-Port8000-TCP:V=7.80%I=7%D=1/12%Time=5E1ACDCD%P=i686-pc-windows-windows%

SF:r(GetRequest,78,"HTTP/1\.1\x20500\x20Internal\x20Server\x20Error\r\nCon

SF:tent-Type:\x20text/plain\r\nDate:\x20Sun,\x2012\x20Jan\x202020\x2007:41

SF::59\x20GMT\r\nConnection:\x20close\r\n\r\n")%r(FourOhFourRequest,78,"HT

SF:TP/1\.1\x20500\x20Internal\x20Server\x20Error\r\nContent-Type:\x20text/

SF:plain\r\nDate:\x20Sun,\x2012\x20Jan\x202020\x2007:41:59\x20GMT\r\nConne

SF:ction:\x20close\r\n\r\n")%r(HTTPOptions,78,"HTTP/1\.1\x20500\x20Interna

SF:l\x20Server\x20Error\r\nContent-Type:\x20text/plain\r\nDate:\x20Sun,\x2

SF:012\x20Jan\x202020\x2007:41:59\x20GMT\r\nConnection:\x20close\r\n\r\n");

MAC Address: F8:77:B8:DF:06:E1 (Samsung Electronics)

Device type: general purpose

Running: Linux 3.X

OS CPE: cpe:/o:linux:linux_kernel:3

OS details: Linux 3.2 - 3.10, Linux 3.2 - 3.16

Uptime guess: 1.491 days (since Sat Jan 11 00:55:22 2020)

Network Distance: 1 hop

TCP Sequence Prediction: Difficulty=260 (Good luck!)

IP ID Sequence Generation: All zeros

Service Info: Device: media device; CPE: cpe:/h:samsung:ue55d7000



TRACEROUTE

HOP RTT     ADDRESS

1   1.23 ms 192.168.169.9



NSE: Script Post-scanning.

Initiating NSE at 12:42

Completed NSE at 12:42, 0.00s elapsed

Initiating NSE at 12:42

Completed NSE at 12:42, 0.00s elapsed

Initiating NSE at 12:42

Completed NSE at 12:42, 0.00s elapsed

Read data files from: C:\Program Files (x86)\Nmap

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .

Nmap done: 1 IP address (1 host up) scanned in 61.86 seconds

           Raw packets sent: 1023 (45.806KB) | Rcvd: 1020 (41.635KB)`

I used various costume components of various authors xchwarze / ha-samsungtv-custom, roberodin ha-samsungtv-custom, jaruba ha-samsungtv-custom. The result is one, only the actual status of the TV is displayed On / Off, but there is no control! Everything works only through port 8001. When using port 8002 in LOG


Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 81, in recv
    bytes_ = sock.recv(bufsize)
  File "/usr/local/lib/python3.7/ssl.py", line 1056, in recv
    return self.read(buflen)
  File "/usr/local/lib/python3.7/ssl.py", line 931, in read
    return self._sslobj.read(len)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 407, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 795, in state_attributes
    for attr in ATTR_TO_PROPERTY
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 796, in <dictcomp>
    if getattr(self, attr) is not None
  File "/config/custom_components/samsungtv_custom/media_player.py", line 286, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_custom/media_player.py", line 248, in _gen_installed_app_list
    app_list = self._remote.app_list()
  File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 175, in app_list
    self._ws_send(payload)
  File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 89, in _ws_send
    self.open()
  File "/usr/local/lib/python3.7/site-packages/samsungtvws/remote.py", line 104, in open
    sslopt=sslopt
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 511, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "/usr/local/lib/python3.7/site-packages/websocket/_handshake.py", line 79, in handshake
    status, resp = _get_resp_headers(sock)
  File "/usr/local/lib/python3.7/site-packages/websocket/_handshake.py", line 150, in _get_resp_headers
    status, resp_headers, status_message = read_headers(sock)
  File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 298, in read_headers
    line = recv_line(sock)
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 102, in recv_line
    c = recv(sock, 1)
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 84, in recv
    raise WebSocketTimeoutException(message)
websocket._exceptions.WebSocketTimeoutException: The read operation timed out

On costume components of the author xchwarze, the token-192.178.189.9.txt file is created in the folder, but it is empty! The TV does not issue a request for granting access to work with HA on any component, I think this is the main problem, but how to send a request for granting access if nothing happens when you click on the Sound, Channel, Source buttons (

P.s

I also checked on which port the standard Samsung TV Android application accesses via TV via Wireshark. Handling and control occurs via port 8001 with a token request on the TV screen

Compatibility with QLED Q55Q7FAM

Hi there,

First and foremost, amazing job! This is by far the most working condition I've had with this TV so far.
THANK YOU BIG TIME.

The only issue I'm having is that the media_player entity is not correctly detecting the TV being ON or OFF. Sometimes the TV is OFF, but the entity is showing OFF, so when I hit the power button on HA (to turn is ON), the actual TV turns off.

This is my config:

media_player:
  - platform: samsungtv_tizen
    host: 192.168.20.252
    port: 8002
    mac: 7C:64:56:XX:XX:XX
    source_list: '{"PlayStation": "ST_HDMI3", "Cable TV": "ST_HDMI4"}'
    update_method: ping
    name: qled_tv
    api_key: "REDACTED"
    device_id: "REDACTED"

I've also seen some exceptions on HA log, but I'm under the impression that after the permission popup on the screen appeared, I no longer get these:

2020-03-20 00:17:46 WARNING (MainThread) [homeassistant.components.media_player] Updating samsungtv_tizen media_player took longer than the scheduled update interval 0:00:15
2020-03-20 00:17:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1253, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 198, in handle_service
    self._platforms.values(), func, call, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 402, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 433, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 527, in async_turn_off
    await self.hass.async_add_job(self.turn_off)
  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_tizen/media_player.py", line 591, in turn_off
    self.send_command("KEY_POWER")
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 446, in send_command
    self._ws.send_key(payload, key_press_delay)
  File "/config/custom_components/samsungtv_tizen/websockets.py", line 181, in send_key
    key_press_delay
  File "/config/custom_components/samsungtv_tizen/websockets.py", line 109, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_tizen/websockets.py", line 152, in open
    response = self._process_api_response(self.connection.recv())
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 313, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 330, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 343, in recv_data_frame
    frame = self.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 377, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 383, in recv_frame
    frame.validate(self.skip_utf8_validation)
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 182, in validate
    raise WebSocketProtocolException("Invalid close opcode.")
websocket._exceptions.WebSocketProtocolException: Invalid close opcode.

Is there a way to improve the reliability of the ON/OFF state?

One minor glitch I also noticed is that the entity status is showing as Netflix, even though is on Cable TV:

image

Is this related to the app_list?

Cannot use entity for automation

Hello,

at first, thank you for your work!

I added it to my HA through HACS. But I cannot use entity for automation - for example I want to turn on light behind my screen when TV is on. But I cannot do this, because TV is added only as entity, not as device.

Is it a solution for this?

Thanks

Marko

Adjustment for QLed Q7F (2017) TV

Hi,

I did some adjustment in your component (media_player.py) to have it work perfectly on my QLed TV.
Basically I was having 2 issue:

  1. After some inactivity period command didn't work at first call -> solution: I always close the WS connection after 10 seconds

  2. The running app was not always shown correcly -> solution: I added an additional (optional) information in app_list to help keep correct information from SmartThings

I also did some additional adjustment in source selection and source_list to give the component more time to update the source based on new selection and to return an empty source list when the TV is off.

I attached here my modified module, obviosly is up to you do whatever you want. I'm avalaible if you need any additional clarification.
media_player.zip

Thanks a lot for your job!!!!!

State always on

I have a problem with media_player entity. Its state is always on. I have tried to set update_method to ping but i have the same problem

Some Google Assistant audio commands not working

I have a 2016 Samsung 6 Series (55) UN55KU6290 TV and all functionality of this component (latest version from HACS (1.4.0)) for the volume works fine (mute, up, down) in the HA UI, but no audio commands work in Google Assistant. I can confirm I get some functionality with the voice commands, like changing the source to particular apps, but audio commands do not work (nothing happens, and then error for volume down):

Mute

2020-02-23 18:26:20 INFO (SyncWorker_5) [root] Sending key KEY

Volume Up

2020-02-23 18:25:04 INFO (SyncWorker_0) [root] Sending key KEY

Volume Down

2020-02-23 18:25:15 INFO (SyncWorker_7) [root] Sending key KEY
2020-02-23 18:25:16 ERROR (MainThread) [homeassistant.components.google_assistant.smart_home] Unexpected error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/smart_home.py", line 57, in _process
    result = await handler(hass, data, inputs[0].get("payload"))
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/smart_home.py", line 176, in handle_devices_execute
    await entities[entity_id].execute(data, execution)
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 488, in execute
    await trt.execute(command, data, params, challenge)
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1428, in execute
    await self._execute_volume_relative(data, params)
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1420, in _execute_volume_relative
    context=data.context,
  File "/usr/src/homeassistant/homeassistant/core.py", line 1204, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 208, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 287, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 283, in _exec
    v = func(v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 205, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 287, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/validators.py", line 285, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: value must be at least 0 for dictionary value @ data['volume_level']
2020-02-23 18:25:16 ERROR (MainThread) [homeassistant.components.google_assistant.smart_home] Error handling message {'inputs': [{'context': {'locale_country': 'US', 'locale_language': 'en'}, 'intent': 'action.devices.EXECUTE', 'payload': {'commands': [{'devices': [{'id': 'media_player.living_room_tv'}], 'execution': [{'command': 'action.devices.commands.volumeRelative', 'params': {'relativeSteps': -1, 'volumeRelativeLevel': -1}}]}]}}], 'requestId': '7397537694740777833'}: {'errorCode': 'unknownError'}

REQUEST: Broadcast Address Config Variable

Hi,

Firstly Thank You for a fantastic improvement over the stock integration.

Unfortunately due to my home wifi / network setup my TV and HA are on different subnets. With the original Integration WOL worked when the subnet was given; but when I try to add this to yours I get a incorrect config error.

Can I request an option to config a broadcast address for the WOL packet?

Thank you!

Can't retrieve current source from TV

First of all, thanks for this great component. It works very well so far. I am able to change between input sources via Home-Assistant, but if I do so the source state is not changed and remains TV/HDMI. If I use the Dashboard and select a source from the Dropdown menu the selected source is showing up for a short time and then the field gets emptied again.
This makes it quit impossible to determine which source is currently selected and build automations based upon this trigger.
Did you observe similar behavior before?
The TV in question is a Samsung UE40NU7189

HA still asking for permission at TV

Hello,

after HA update my TV still shows dialogue about HA wants to get permission every time I start TV.

Is it on my side or is it a bug?

Thank you

Marko

Home Assistant full unresponsive a soon as v1.4.3 installed and used

As soon as version v1.4.3 via HACS is installed and configured in configuration.yaml my entire home assistant is unresponsive. As soon as I delete the config and uninstall via hacs it comes back to normal.

If installed and configured I see the CPU of HA (via Glances) going to almost 100% (always 89.1%) where user cpu is 78.8 and system 10.2.

something is definitely VERY WRONG here

If configured in the first few minutes it works well and even the TV responds to some commands, but they take very long time to "reach" the TV.

My config:
media_player:

  • platform: samsungtv_tizen
    host: 192.168.1.x
    port: 8002
    mac: xxx

i see these errors in logging:
2020-03-08 14:03:28 ERROR (MainThread) [custom_components.samsungtv_tizen.media_player] Unsupported media type

After upgrade to Homeassistant 0.105.1, exception in homeassistant.core

After upgrading to homeassistant 0.105.1, the component crashes with the following exception:

2020-02-06 18:41:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 774, in capability_attributes
    source_list = self.source_list
  File "/config/custom_components/samsungtv_custom/media_player.py", line 319, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_custom/media_player.py", line 229, in _gen_installed_app_list
    app_list = self._remote.app_list()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 180, in app_list
    response = json.loads(self.connection.recv())
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 310, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 327, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 358, in recv_data_frame
    self.pong(frame.data)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 301, in pong
    self.send(payload, ABNF.OPCODE_PONG)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 250, in send
    return self.send_frame(frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 275, in send_frame
    l = self._send(data)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 445, in _send
    return send(self.sock, data)
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 117, in send
    return sock.send(data)
  File "/usr/local/lib/python3.7/ssl.py", line 1003, in send
    return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe

A little later in the log, the following exception is recorded:

2020-02-06 18:41:34 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/websocket/_socket.py", line 81, in recv
    bytes_ = sock.recv(bufsize)
  File "/usr/local/lib/python3.7/ssl.py", line 1056, in recv
    return self.read(buflen)
  File "/usr/local/lib/python3.7/ssl.py", line 931, in read
    return self._sslobj.read(len)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 774, in capability_attributes
    source_list = self.source_list
  File "/config/custom_components/samsungtv_custom/media_player.py", line 319, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_custom/media_player.py", line 229, in _gen_installed_app_list
    app_list = self._remote.app_list()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 180, in app_list
    response = json.loads(self.connection.recv())
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 310, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 327, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 340, in recv_data_frame
    frame = self.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 374, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 361, in recv_frame
    self.recv_header()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 309, in recv_header
    header = self.recv_strict(2)
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 396, in recv_strict
    bytes_ = self.recv(min(16384, shortage))
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 449, in _recv
    return recv(self.sock, bufsize)
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 84, in recv
    raise WebSocketTimeoutException(message)
websocket._exceptions.WebSocketTimeoutException: The read operation timed out

Script doesn't work

Script doesn't work:

`'1583322636490':
alias: Play PS4
sequence:

  • data:
    entity_id: media_player.samsung_tv_remote
    media_content_id: ST_HDMI1
    media_content_type: send_key
    service: media_player.turn_on
  • entity_id: media_player.playstation_4
    service: media_player.turn_on`

(pastebin link here)

Error:
Failed to call service script/1583322636490. extra keys not allowed @ data['media_content_id']

(No idea why the script is formatted like this and not as code but the indentations seem to be correct. The quotation marks from "send_key" and "ST_HDMI1" were removed by the HA script UI)

HA error in logs

Hi,

I've successfully installed plugin, but I'm getting some errors in logs, see below:

2020-01-05 21:33:09 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 408, in _async_add_entity
await entity.async_update_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 286, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 796, in state_attributes
for attr in ATTR_TO_PROPERTY
File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 797, in
if getattr(self, attr) is not None
File "/config/custom_components/samsungtv_custom/media_player.py", line 319, in source_list
self._gen_installed_app_list()
File "/config/custom_components/samsungtv_custom/media_player.py", line 229, in _gen_installed_app_list
app_list = self._remote.app_list()
File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 179, in app_list
self._ws_send(payload)
File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 93, in _ws_send
self.open()
File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 108, in open
sslopt=sslopt
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 511, in create_connection
websock.connect(url, **options)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 220, in connect
options.pop('socket', None))
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 186, in _open_socket
raise error
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 170, in _open_socket
sock.connect(address)
OSError: [Errno 113] Host is unreachable

Any ideas?

looping "Sending key KEY"

Is it normal to have a key sending every few seconds without actually sending anything? for example:

2020-02-26 13:30:46 INFO (SyncWorker_13) [root] Sending key KEY
2020-02-26 13:31:08 INFO (SyncWorker_0) [root] Sending key KEY
2020-02-26 13:31:08 INFO (SyncWorker_0) [root] Sending key KEY
2020-02-26 13:31:30 INFO (SyncWorker_19) [root] Sending key KEY
2020-02-26 13:31:52 INFO (SyncWorker_4) [root] Sending key KEY
2020-02-26 13:31:52 INFO (SyncWorker_4) [root] Sending key KEY
2020-02-26 13:32:14 INFO (SyncWorker_16) [root] Sending key KEY
2020-02-26 13:32:36 INFO (SyncWorker_1) [root] Sending key KEY
2020-02-26 13:32:36 INFO (SyncWorker_1) [root] Sending key KEY
2020-02-26 13:32:57 INFO (SyncWorker_15) [root] Sending key KEY

my conf:

media_player:
  - platform: samsungtv_tizen
    host: 192.168.1.xx
    port: 8002
    mac: 'b8:bc:5b:c7:xx:xx'
    api_key: 'myapikey'
    device_id: 'mydeviceid'

ST_HDMI1 command

Hi!
I manage to control the TV, everything works fine, except for the cloud commands - ST_HDMI1, ST_HDMI2, ST_HDMI3
What may be wrong?
Config:

media_player:

  • platform: samsungtv_tizen
    host: 10.4.3.119
    port: 8002
    mac: 00:c3:f4:20:74:62
    source_list: '{"TV": "KEY_TV", "HDMI": "KEY_HDMI", "TEST": "ST_HDMI2"}'
    api_key: 'a3045299-f3a3-4b7e- -'
    device_id: '8a6d5331-a085-48df- -'

Support for Samsung 7 Series NU7670 (UE49NU7670)

Hello!

I have a Samsung 7 Series NU7670 Tizen based smart TV (Full model #UE49NU7670) but i cant seem to get it working with home assistant in any way other than via the SmartThings integration.

Ports 8001 (HTTP) and 8002 (HTTPS) are open, but i only get either a 401 for the root URL path (192.168.1.100:8001/), or 404 for any for the possible API paths i've seen. (like /api/v2)

I've checked and made sure remote access is allowed in the settings. Attempting to connect with the default "SamsungTV" integrating from the UI just returns "Aborted: Unable to connect to this Samsung TV device."

I'm comfortable with WireShark and the like so happy to do some prodding if needs be.

Feature Proposal: Push states from SmartThings

Hi,

glad to see you incorporated the SmartThings stuff so quickly. This is the best component for Tizen TVs so far, thanks for your effort and great work!

I've been tinkering around with the SmartThings API as well and may have found a way to improve upon the component, albeit quite hacky:

First thing is to install this SmartApp in SmartThings and set it up to forward the switch events of your TV to your local Home Assistant instance:

/**
 *  Home Assistant Event Forwarder
 *
 *  Copyright 2020 caphm
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Home Assistant Event Forwarder",
    namespace: "caphm",
    author: "caphm",
    description: "Forwards events to Home Assistant",
    category: "",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/[email protected]",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/[email protected]")

preferences {
    section("Home Assistant"){
		input "url", "text", title: "Home Assistant URL", description: "Publicly accessible URL of your Home Assistant installation (no trailing / )", required: true
		input "accessToken", "text", title: "Access Token", description: "A long-lived access token generated in Home Assistant", required: true
        input "eventType", "text", title: "Event Type", description: "Forwarded events will show up under this event type", required: true
	}

	section("Choose what events you want to forward"){
		input "accelerationSensor", "capability.accelerationSensor", title: "Acceleration Sensor", required: false, multiple: true
		input "alarm", "capability.alarm", title: "Alarm", required: false, multiple: true
		input "battery", "capability.battery", title: "Battery", required: false, multiple: true
		input "beacon", "capability.beacon", title: "Beacon", required: false, multiple: true
		input "button", "capability.button", title: "Button", required: false, multiple: true
		input "carbonMonoxideDetector", "capability.carbonMonoxideDetector", title: "Carbon Monoxide Detector", required: false, multiple: true
		input "colorControl", "capability.colorControl", title: "Color Control", required: false, multiple: true
		input "contactSensor", "capability.contactSensor", title: "Contact Sensor", required: false, multiple: true
		input "doorControl", "capability.doorControl", title: "Door Control", required: false, multiple: true
		input "energyMeter", "capability.energyMeter", title: "Energy Meter", required: false, multiple: true
		input "illuminanceMeasurement", "capability.illuminanceMeasurement", title: "Illuminance Measurement", required: false, multiple: true
		input "imageCapture", "capability.imageCapture", title: "Image Capture", required: false, multiple: true
		input "indicator", "capability.indicator", title: "Indicator", required: false, multiple: true
		input "lock", "capability.lock", title: "Lock", required: false, multiple: true
		input "mediaController", "capability.mediaController", title: "Media Controller", required: false, multiple: true
		input "motionSensor", "capability.motionSensor", title: "Motion Sensor", required: false, multiple: true
		input "musicPlayer", "capability.musicPlayer", title: "Music Player", required: false, multiple: true
		input "powerMeter", "capability.powerMeter", title: "Power Meter", required: false, multiple: true
		input "presenceSensor", "capability.presenceSensor", title: "Presence Sensor", required: false, multiple: true
		input "relativeHumidityMeasurement", "capability.relativeHumidityMeasurement", title: "Relative Humidity Measurement", required: false, multiple: true
		input "relaySwitch", "capability.relaySwitch", title: "Relay Switch", required: false, multiple: true
		input "sensor", "capability.sensor", title: "Sensor", required: false, multiple: true
		input "signalStrength", "capability.signalStrength", title: "Signal Strength", required: false, multiple: true
		input "sleepSensor", "capability.sleepSensor", title: "Sleep Sensor", required: false, multiple: true
		input "smokeDetector", "capability.smokeDetector", title: "Smoke Detector", required: false, multiple: true
		input "speechRecognition", "capability.speechRecognition", title: "Speech Recognition", required: false, multiple: true
		input "stepSensor", "capability.stepSensor", title: "Step Sensor", required: false, multiple: true
		input "switchv", "capability.switch", title: "Switch", required: false, multiple: true
		input "switchLevel", "capability.switchLevel", title: "Switch Level", required: false, multiple: true
		input "temperatureMeasurement", "capability.temperatureMeasurement", title: "Temperature Measurement", required: false, multiple: true
		input "thermostat", "capability.thermostat", title: "Thermostat", required: false, multiple: true
		input "thermostatCoolingSetpoint", "capability.thermostatCoolingSetpoint", title: "Thermostat Cooling Setpoint", required: false, multiple: true
		input "threeAxis", "capability.threeAxis", title: "Three Axis", required: false, multiple: true
		input "touchSensor", "capability.touchSensor", title: "TouchSensor", required: false, multiple: true
		input "valve", "capability.valve", title: "Valve", required: false, multiple: true
		input "waterSensor", "capability.waterSensor", title: "Water Sensor", required: false, multiple: true
	}
}

def installed() {
	log.debug "Installed, forwarding events to ${settings.url}"
	subscribeToEvents()
    initialize()
}

def updated() {
	log.debug "Updated, forwarding events to ${settings.url}"
	unsubscribe()
	subscribeToEvents()
    initialize()
}

def initialize() {
	subscribe(app, eventHandler)
}

def subscribeToEvents() {
	subscribe(accelerationSensor, "acceleration ", eventHandler)

	subscribe(alarm, "alarm", eventHandler)
	subscribe(battery, "battery", eventHandler)
	subscribe(beacon, "presence", eventHandler)
	subscribe(button, "button", eventHandler)
	subscribe(carbonMonoxideDetector, "carbonMonoxide", eventHandler)
	subscribe(colorControl, "hue", eventHandler)
    subscribe(colorControl, "saturation", eventHandler)

	subscribe(contactSensor, "contact", eventHandler)
	subscribe(doorControl, "door", eventHandler)
	subscribe(energyMeter, "energy", eventHandler)
	subscribe(illuminanceMeasurement, "illuminance", eventHandler)
	subscribe(imageCapture, "image", eventHandler)
	subscribe(indicator, "indicatorStatus", eventHandler)
	subscribe(lock, "lock", eventHandler)

	subscribe(mediaController, "activities", eventHandler)
   	subscribe(mediaController, "currentActivity", eventHandler)

	subscribe(motionSensor, "motion", eventHandler)
	subscribe(musicPlayer, "status", eventHandler)
	subscribe(musicPlayer, "level", eventHandler)
	subscribe(musicPlayer, "trackDescription", eventHandler)
	subscribe(musicPlayer, "trackData", eventHandler)
	subscribe(musicPlayer, "mute", eventHandler)

	subscribe(powerMeter, "power", eventHandler)
	subscribe(presenceSensor, "presence", eventHandler)

	subscribe(relativeHumidityMeasurement, "humidity", eventHandler)
	subscribe(relaySwitch, "switch", eventHandler)
	subscribe(sensor, "sensor", eventHandler)
	subscribe(signalStrength, "lqi", eventHandler)
	subscribe(signalStrength, "rssi", eventHandler)
	subscribe(sleepSensor, "sleeping", eventHandler)
	subscribe(smokeDetector, "smoke", eventHandler)
	subscribe(speechRecognition, "phraseSpoken", eventHandler)

	subscribe(stepSensor, "goals", eventHandler)
	subscribe(stepSensor, "steps", eventHandler)
	subscribe(switchv, "switch", eventHandler)
	subscribe(switchLevel, "level", eventHandler)
	subscribe(temperatureMeasurement, "temperature", eventHandler)

	subscribe(thermostat, "temperature", eventHandler)
	subscribe(thermostat, "heatingSetpoint", eventHandler)
	subscribe(thermostat, "coolingSetpoint", eventHandler)
	subscribe(thermostat, "thermostatSetpoint", eventHandler)
	subscribe(thermostat, "thermostatMode", eventHandler)
	subscribe(thermostat, "thermostatFanMode", eventHandler)
	subscribe(thermostat, "thermostatOperatingState", eventHandler)
    
	subscribe(thermostatCoolingSetpoint, "coolingSetpoint", eventHandler)
	subscribe(threeAxis, "threeAxis", eventHandler)

	subscribe(touchSensor, "touch", eventHandler)
	subscribe(valve, "contact", eventHandler)
	subscribe(waterSensor, "water", eventHandler)
}

def eventHandler(evt) {
    def state_changed = evt.isStateChange()
	def json_body = [
            id: evt.deviceId, 
			date: evt.isoDate,
        	value: evt.value, 
            name: evt.name, 
            display_name: evt.displayName, 
            description: evt.descriptionText,
            source: evt.source, 
            state_changed: evt.isStateChange(),
            physical: evt.isPhysical(),
            location_id: evt.locationId,
            hub_id: evt.hubId, 
            smartapp_id: evt.installedSmartAppId
        ]
    log.debug("Forwarding $json_body")

	def json_params = [
  		uri: settings.url + "/api/events/" + settings.eventType,
  		success: successClosure,
        headers: [
        	Authorization: "Bearer " + settings.accessToken
        ],
	  	body: json_body
	]
    
    try {
		httpPostJson(json_params)
	} catch (e) {
    	log.error "Event forwarding failed: $e"
	}
}

def successClosure = { response ->
  log.debug "Event forwarded successfully, $response"
}

As the name says, this will forward events to Home Assistant and publish them on the event bus under the event type specified in the settings.

If you could add an event listener that intercepts these events, the state updates for on/off could become as good as realtime.
Because the event type can be chosen freely when installing the smartapp, could you make this a configuration option to set it accordingly?

If you don't have any time on your hands, I could probably implement this on the weekend and createa PR.

SmartThings

I have updated to the latest version and added the smarthings part to the config.
Now I donโ€™t see the selected source anymore and I get the following error:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 793, in state_attributes
    for attr in ATTR_TO_PROPERTY
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 794, in <dictcomp>
    if getattr(self, attr) is not None
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 391, in source
    running_app = self._remote.get_running_app()
  File "/config/custom_components/samsungtv_tizen/remote.py", line 233, in get_running_app
    root = json.loads(data.encode('UTF-8'))
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The Frame 65" 2018 - Art Mode

This version is working much better than any others I have tried, but I still can't get Art Mode to work on my Samsung Frame TV. I have tried to manually fire lots of Key Codes including KEY_AMBIENT and nothing seems to work :(

Thanks for all the hard work!
Dave.

Error doing job: Task exception was never retrieved

Installation worked fine. HA media player is here, but protocoll + error in log:

Protokolldetails ( WARNING )
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:284
First occurred: 17:15:45 (1 occurrences)
Last logged: 17:15:45
Updating state for media_player.tv_eg_2 (<class 'custom_components.samsungtv_tizen.media_player.SamsungTVDevice'>) took 0.575 seconds. Please report it to the custom component author.

Logger: homeassistant.core
Source: custom_components/samsungtv_tizen/websockets.py:241
First occurred: 17:15:33 (1 occurrences)
Last logged: 17:15:33
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/websocket/socket.py", line 102, in recv
bytes
= _recv()
File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 84, in _recv
return sock.recv(bufsize)
File "/usr/local/lib/python3.7/ssl.py", line 1056, in recv
return self.read(buflen)
File "/usr/local/lib/python3.7/ssl.py", line 931, in read
return self._sslobj.read(len)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
attr = self.capability_attributes
File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 781, in capability_attributes
source_list = self.source_list
File "/config/custom_components/samsungtv_tizen/media_player.py", line 532, in source_list
self._gen_installed_app_list()
File "/config/custom_components/samsungtv_tizen/media_player.py", line 337, in _gen_installed_app_list
app_list = self._ws.app_list()
File "/config/custom_components/samsungtv_tizen/websockets.py", line 241, in app_list
response = self._process_api_response(self.connection.recv())
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 313, in recv
opcode, data = self.recv_data()
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 330, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 343, in recv_data_frame
frame = self.recv_frame()
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 377, in recv_frame
return self.frame_buffer.recv_frame()
File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 361, in recv_frame
self.recv_header()
File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 309, in recv_header
header = self.recv_strict(2)
File "/usr/local/lib/python3.7/site-packages/websocket/abnf.py", line 396, in recv_strict
bytes
= self.recv(min(16384, shortage))
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 452, in _recv
return recv(self.sock, bufsize)
File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 105, in recv
raise WebSocketTimeoutException(message)
websocket._exceptions.WebSocketTimeoutException: The read operation timed out

Error with setting up the plugin

Hello!

After last update (v1.3.3) I have a problem with setting up the plugin after HASS restart. I've tried completely removing plugin files and configuration, restarting and providing that again, but I always run into the same result.

Here's output from the dev tools log:

Sun Feb 09 2020 16:58:30 GMT+0100 (CET)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 102, in recv
    bytes_ = _recv()
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 84, in _recv
    return sock.recv(bufsize)
  File "/usr/local/lib/python3.7/ssl.py", line 1056, in recv
    return self.read(buflen)
  File "/usr/local/lib/python3.7/ssl.py", line 931, in read
    return self._sslobj.read(len)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 774, in capability_attributes
    source_list = self.source_list
  File "/config/custom_components/samsungtv_custom/media_player.py", line 320, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_custom/media_player.py", line 230, in _gen_installed_app_list
    app_list = self._remote.app_list()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 179, in app_list
    self._ws_send(payload)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 93, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 111, in open
    response = json.loads(self.connection.recv())
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 314, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 331, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 344, in recv_data_frame
    frame = self.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 378, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 361, in recv_frame
    self.recv_header()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 309, in recv_header
    header = self.recv_strict(2)
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 396, in recv_strict
    bytes_ = self.recv(min(16384, shortage))
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 453, in _recv
    return recv(self.sock, bufsize)
  File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 105, in recv
    raise WebSocketTimeoutException(message)
websocket._exceptions.WebSocketTimeoutException: The read operation timed out

Thanks for your work and thanks in advance for any assistance here :)

keeps asking authorization with popup

tv model: UE43RU7170U
with latest update keeps asking authorization with popup on TV on every send_key and nothing happens, before this update was working.

in custom_components/samsungtv_tizen/ the file token-192.168.1.20.txt is empty. i tryed to delete but is recreated empty when popup appear on tv

api_key and device_id are correctly set. if i switch with remote from HDMI to TV I can see the media titles change in the lovelace card

I could swear the absolute first time i tryed to change the source from HDMI to TV worked, but after that after than and after many HASSIO reboot il couldn't do that again...

entity not available

I'm getting this:

Update for media_player.customtv fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper result = method(*args, **kwargs) File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper result = method(*args, **kwargs) File "/config/custom_components/samsungtv_tizen/media_player.py", line 320, in update smartthings.device_update(self) File "/config/custom_components/samsungtv_tizen/smartthings.py", line 40, in device_update data = resp.json() File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

HA 106.3 on Rpi4, Samsung NU8000. It sporadically works but most times I'm getting this error. IP, MAC, Device_id and api_key are correct.

python3.8 websocket timeout

2020-01-06 14:56:00 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/socket.py", line 102, in recv
bytes
= _recv()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_socket.py", line 84, in _recv
return sock.recv(bufsize)
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/ssl.py", line 1226, in recv
return self.read(buflen)
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/ssl.py", line 1101, in read
return self._sslobj.read(len)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 408, in _async_add_entity
await entity.async_update_ha_state()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 286, in async_update_ha_state
self._async_write_ha_state()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/media_player/init.py", line 794, in state_attributes
state_attr = {
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/media_player/init.py", line 797, in
if getattr(self, attr) is not None
File "/mnt/dietpi_userdata/homeassistant/custom_components/samsungtv_custom/media_player.py", line 319, in source_list
self._gen_installed_app_list()
File "/mnt/dietpi_userdata/homeassistant/custom_components/samsungtv_custom/media_player.py", line 229, in _gen_installed_app_list
app_list = self._remote.app_list()
File "/mnt/dietpi_userdata/homeassistant/custom_components/samsungtv_custom/samsungtvws/remote.py", line 179, in app_list
self._ws_send(payload)
File "/mnt/dietpi_userdata/homeassistant/custom_components/samsungtv_custom/samsungtvws/remote.py", line 93, in _ws_send
self.open()
File "/mnt/dietpi_userdata/homeassistant/custom_components/samsungtv_custom/samsungtvws/remote.py", line 111, in open
response = json.loads(self.connection.recv())
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_core.py", line 314, in recv
opcode, data = self.recv_data()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_core.py", line 331, in recv_data
opcode, frame = self.recv_data_frame(control_frame)
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_core.py", line 344, in recv_data_frame
frame = self.recv_frame()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_core.py", line 378, in recv_frame
return self.frame_buffer.recv_frame()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_abnf.py", line 361, in recv_frame
self.recv_header()
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_abnf.py", line 309, in recv_header
header = self.recv_strict(2)
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/abnf.py", line 396, in recv_strict
bytes
= self.recv(min(16384, shortage))
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_core.py", line 453, in _recv
return recv(self.sock, bufsize)
File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/websocket/_socket.py", line 105, in recv
raise WebSocketTimeoutException(message)
websocket._exceptions.WebSocketTimeoutException: The read operation timed out

Entity Picture support

It would be awesome if it was possibile to support the entity_picture attribute on the media_player entity, so the media control card could display a picture of what currently is on the TV, like:

  • logo of the tv channel
    image
  • logo of the active app
    image

out of sync error

i keep seeing in logs the error

media_player.ourtv: Sources out of sync. Restart Home Assistant

the tv is controllable as expected but every now and then it does not know the state of the tv (i.e. it thinks the tv is off when it is on or vice versa).
tv is controlled locally from a docker container.

ue48ju7500

with this series and with this configuration not work:

  • platform: samsungtv_tizen
    host: 192.168.1.13
    port: 8001
    mac: 24:4B:03:C9:C6:91

Samsung TV disappears after latest update

My Samsung TV (QE55Q7CGM) disappeared from home assistant after the update 1.2.4.
I have the following error in the log:

Thu Dec 26 2019 19:46:18 GMT+0100 (CET)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 408, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 286, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 796, in state_attributes
    for attr in ATTR_TO_PROPERTY
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 797, in <dictcomp>
    if getattr(self, attr) is not None
  File "/config/custom_components/samsungtv_custom/media_player.py", line 319, in source_list
    self._gen_installed_app_list()
  File "/config/custom_components/samsungtv_custom/media_player.py", line 229, in _gen_installed_app_list
    app_list = self._remote.app_list()
TypeError: 'NoneType' object is not callable

Turn on not always work on Q7/Q9 2018 model

I have two TV Q7FN 55" and Q9FN 65", this is the only component work.
But i have problem with turn on.

LAN not work on my TV, it only work for wireless LAN, so in order for ON command work i do following on TV Settings:
Settings > General > Network settings > Expert settings > Power on with mobile (turn on) and enable IP remote .

It work fine with OFF command, but when it off press on, sometime work and sometime not.

I try the command and see that it use only KEY_POWER for both on/off, and some time the component not update correct state. So how to fix the problems?
Update: Smarthings App use same API and could show accurate state of the TVs and both of my TV could not use WOL to turn on.

Tv's not switching on and HA log

Setup

- platform: samsungtv_tizen
  name: Bedroom TV
  host: 192.168.88.72
  broadcast_address: 192.168.88.72 **<--- Not sure if this is needed**
  port: 8002
  api_key: "<token>"
  device_id: "<token>"
  show_channel_number: true

Logger: homeassistant.core
First occured: 4:17:06 PM (4 occurences)
Last logged: 4:17:27 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 434, in _async_add_entity
await entity.async_update_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
attr = self.capability_attributes
File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 774, in capability_attributes
source_list = self.source_list
File "/config/custom_components/samsungtv_tizen/media_player.py", line 446, in source_list
self._gen_installed_app_list()
File "/config/custom_components/samsungtv_tizen/media_player.py", line 301, in _gen_installed_app_list
app_list = self._ws.app_list()
File "/config/custom_components/samsungtv_tizen/websockets.py", line 237, in app_list
'to': 'host'
File "/config/custom_components/samsungtv_tizen/websockets.py", line 109, in _ws_send
self.open()
File "/config/custom_components/samsungtv_tizen/websockets.py", line 149, in open
sslopt=sslopt
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 514, in create_connection
websock.connect(url, **options)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
options.pop('socket', None))
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 189, in _open_socket
raise error
File "/usr/local/lib/python3.7/site-packages/websocket/_http.py", line 172, in _open_socket
sock.connect(address)
socket.timeout: timed out

Media title info

I wonder if there a way to pull out the media title? Does the tizenOS expose an api? Like when watching CNN gather the following from the HA states api

"media_title": "CNN"

NU8000 not working anymore

Hi!

After last update (v1.3.3) I can successfully setup my NU8000 TV, ping works as well. The problem is that the only thing I can control is device volume via slider/knob. Even 'vol +/-' or 'on/off' buttons does not work. No errors in log.

Heres my config:

media_player:
  - platform: samsungtv_custom
    host: 192.168.8.166
    port: 8002
    mac: !secret mac_samsung
    update_method: "ping"
    source_list: '{"TV": "KEY_TV", "HDMI": "KEY_HDMI"}'
    app_list: '{"Netflix": "11101200001","YouTube": "111299001912","Internet": "org.tizen.browser"}'

Just to be clear. Everything was working as intended before this update. Even though I did not have 'app_list' set up at that time.
Any ideas?

EDIT: Surprisingly play_media service works really well. Too bad I cannot turn on/off my TV, even manually via proper service. It would be so perfect if I could.

set_volume does not work

I can't set the Volume using set_volume

My setup: Samsung UE65MU7000 Series (2017 Model)
Port 8002
Mac Address set

Broken pipe on UE55NU8042

Hello,

I have a TV as in the subject above. I set up this great Tizen component today (HA 0.107 and Tizen 1.4.6) - with SmartThings API configured, but without custom App list yet.

Now, after setup and HA restart I managed successfully open the browser on TV calling service media_player.play_media from HA as described in the docs, but.... it was successful JUST ONCE. Any subsequent attempts are giving IMMEDIATELY (without any waiting) the "Broken pipe error" in a log as shown below.

Any hits? Isn't it connected with too low connection timeout limit - a timeout on getting a response from TV?

Apr 04 03:37:18 hassbian hass[32378]: 2020-04-04 03:37:18 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1563468176] [Errno 32] Broken pipe
Apr 04 03:37:18 hassbian hass[32378]: Traceback (most recent call last):
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
Apr 04 03:37:18 hassbian hass[32378]:     connection.context(msg),
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1234, in async_call
Apr 04 03:37:18 hassbian hass[32378]:     await asyncio.shield(self._execute_service(handler, service_call))
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1257, in _execute_service
Apr 04 03:37:18 hassbian hass[32378]:     await handler.func(service_call)
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 198, in handle_service
Apr 04 03:37:18 hassbian hass[32378]:     self._platforms.values(), func, call, required_features
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 402, in entity_service_call
Apr 04 03:37:18 hassbian hass[32378]:     future.result()  # pop exception if have
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 599, in async_request_call
Apr 04 03:37:18 hassbian hass[32378]:     await coro
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 433, in _handle_entity_call
Apr 04 03:37:18 hassbian hass[32378]:     await result
Apr 04 03:37:18 hassbian hass[32378]:   File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/media_player.py", line 704, in async_play_media
Apr 04 03:37:18 hassbian hass[32378]:     self._ws.open_browser(media_id)
Apr 04 03:37:18 hassbian hass[32378]:   File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 228, in open_browser
Apr 04 03:37:18 hassbian hass[32378]:     url
Apr 04 03:37:18 hassbian hass[32378]:   File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 218, in run_app
Apr 04 03:37:18 hassbian hass[32378]:     'metaTag': meta_tag
Apr 04 03:37:18 hassbian hass[32378]:   File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 112, in _ws_send
Apr 04 03:37:18 hassbian hass[32378]:     self.connection.send(payload)
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 253, in send
Apr 04 03:37:18 hassbian hass[32378]:     return self.send_frame(frame)
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 278, in send_frame
Apr 04 03:37:18 hassbian hass[32378]:     l = self._send(data)
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 448, in _send
Apr 04 03:37:18 hassbian hass[32378]:     return send(self.sock, data)
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_socket.py", line 157, in send
Apr 04 03:37:18 hassbian hass[32378]:     return _send()
Apr 04 03:37:18 hassbian hass[32378]:   File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_socket.py", line 139, in _send
Apr 04 03:37:18 hassbian hass[32378]:     return sock.send(data)
Apr 04 03:37:18 hassbian hass[32378]:   File "/usr/local/lib/python3.7/ssl.py", line 984, in send
Apr 04 03:37:18 hassbian hass[32378]:     return self._sslobj.write(data)
Apr 04 03:37:18 hassbian hass[32378]: BrokenPipeError: [Errno 32] Broken pipe

My TV is displayed as unnamed_device

Here's my config from configuration.yaml:

media_player:
  - platform: samsungtv_tizen
    name: Samsung TV
    host: 192.168.0.XXX
    port: 8002
    mac: XX:XX:XX:XX:XX:XX
    api_key: "XXXXXX"
    device_id: "XXXXXX"
    source_list: >-
      {
        "Apple TV": "ST_HDMI1",
        "PlayStation 4": "ST_HDMI2"
      }
    app_list: >-
      {
        "Netflix": "11101200001",
        "YouTube": "111299001912"
        "Internet": "org.tizen.browser"
      }

However, I have two entities that mirror each other: media_player.samsung_tv and media_player.unnamed_device.

image

Home Assistant also says my TV's entity does not have a unique ID.

image

How can I set up my TV properly and get rid of unnamed_device?

SmartThings Update Sometimes Fails

Hi @jaruba.
Can you tell me something about this error?

Logger: homeassistant.helpers.entity
Source: custom_components/samsungtv_tizen/smartthings.py:40 
First occured: 18:23:57 (122 occurences) 
Last logged: 19:16:16

Update for media_player.samsung_tv_remote fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/samsungtv_tizen/media_player.py", line 357, in update
    smartthings.device_update(self)
  File "/config/custom_components/samsungtv_tizen/smartthings.py", line 40, in device_update
    data = resp.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It works, but in the error log

Thank you for your work. I used "roberodin / ha-samsungtv-custom" and now decided to try your component. Of the pluses, I noticed more quickly the determination that the TV was turned off. Also was able to add USB to source_list.
My configuration "Samsung 5 Series UE32M5500 (2017)", HA v107.4:

  • platform: samsungtv_tizen
    host: 192.168.8.6
    port: 8002
    mac: <hide>
    source_list: '{"TV": "KEY_TV", "HDMI": "KEY_HDMI", "USB": "KEY_SOURCE+KEY_LEFT+KEY_LEFT+KEY_LEFT+KEY_RIGHT+KEY_ENTER"}'

Visually, everything works, but there are the following errors in the log, how can I remove them?

2020-03-21 17:13:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 434, in _async_add_entity
    await entity.async_update_ha_state()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py", line 781, in capability_attributes
    source_list = self.source_list
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/media_player.py", line 532, in source_list
    self._gen_installed_app_list()
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/media_player.py", line 337, in _gen_installed_app_list
    app_list = self._ws.app_list()
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 237, in app_list
    'to': 'host'
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 109, in _ws_send
    self.open()
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 149, in open
    sslopt=sslopt
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 514, in create_connection
    websock.connect(url, **options)
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
    options.pop('socket', None))
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect
    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_http.py", line 189, in _open_socket
    raise error
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_http.py", line 172, in _open_socket
    sock.connect(address)
socket.timeout: timed out

and next

2020-03-21 17:14:14 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    attr = self.capability_attributes
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py", line 781, in capability_attributes
    source_list = self.source_list
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/media_player.py", line 532, in source_list
    self._gen_installed_app_list()
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/media_player.py", line 337, in _gen_installed_app_list
    app_list = self._ws.app_list()
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 237, in app_list
    'to': 'host'
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 109, in _ws_send
    self.open()
  File "/home/homeassistant/.homeassistant/custom_components/samsungtv_tizen/websockets.py", line 149, in open
    sslopt=sslopt
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 514, in create_connection
    websock.connect(url, **options)
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_core.py", line 223, in connect
    options.pop('socket', None))
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_http.py", line 120, in connect
    sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_http.py", line 189, in _open_socket
    raise error
  File "/srv/homeassistant/lib/python3.7/site-packages/websocket/_http.py", line 172, in _open_socket
    sock.connect(address)
OSError: [Errno 113] No route to host

Google Assistant voice control?

Hi! Thanks for taking the time with this component. I'm currently looking at a way to control the TV with Home Assistant -> Google Assistant. I noticed the component says you can use your voice. What is the proper workflow here?

I currently have your component loaded in HA and can issue commands via clicking. How do I add it into Google Home/Google Assistant? Samsung says if you link it to SmartThings and then set it up via that, it adds the TV. Unfortunately, for some reason Google Home only sees my TV as a light switch. On/Off is all I can control at that point, and it can't even turn it on I believe. Using the SmartThings app works with ease as expected. But I really want to add Google Assistant to be able to control the TV along with my lights in a scene, etc. Is this not possible yet?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.