Control newer Samsung TVs


#62

@MrUart232 it has a slider or volume up/down button?


#63

I get the same error on Hass OS.


#64

I get the error…

Traceback (most recent call last):
  File "samsungtv.py", line 13, in <module>
    from homeassistant.components.media_player import (
ImportError: No module named homeassistant.components.media_player

#65

Had some progress, deleted everything in the media_player folder and restarted so it picked up the built in component instead. No errors on restart and it can now sense when the TV is on and off, which is an improvement on when I tried it a year or so ago and gave up.

Next put the custom component back in and restarted, now it doesn’t error anymore and I have control of the volume. This implies there’s something missing from the set up of this component that the built in one installs correctly.

Obviously not much you can do with this as is, really needs play and pause to be useful, but appreciate the effort.


#66

I noticed that there has been some work on the Samsung TVs in the Node-Red library https://flows.nodered.org/node/node-red-contrib-newsamsungtv would the associated file help make the needed components?

They seem to preform most of the needed functions. I am not that good with the programming, but hoping to maybe come up with an IR transmitter.


#67

So I finally got it working… @Kent, is your TV connected to the internet via WiFi or ethernet?


#68

Can you share how


#69

I have a 2018 Q7F. I found that I could not control it when the TV was connected to my network via WiFi but it works like a charm when connected via Ethernet. Like @Kent, I did not use the custom script… Here is my config:

media_player:
  - platform: samsungtv
    host: 192.168.1.117
    mac: !secret samsung_mac
    port: 8001
    name: Samsung TV

#70

Nice, that was too easy. thanks


#71

I’m using WiFi for my setup and it works fine, pls. make sure that you configured the WiFi mac adress right. @dapowers87


#72

I had updated the MAC to the WiFi MAC, so I just don’t know why it isn’t working for me. I’m sure it is some small thing I am overlooking. Thanks for continually checking back in, Kent.


#73

Have you tried this using Node-RED from within HA? This seems very promising!


#74

Hi everyone!
I own a Samsung Frame 2018 (LS03). It kinda works well with the samsungtv platform, except for the turn off command. The main issue I have is with the let’s call it frame mode (static image with a picture).

  • When I send the turn on command, it goes from complete shutdown (black screen) into whichever mode it was the last time It shut down (frame or tv mode). The turn on command does not change from frame mode to TV mode.
  • When I send the turn off command it switches between frame mode and tv mode (in both directions)

Thus, if I turn it on it may go into picture mode and then I have to send the turn off command for it to go into tv mode. So there’s no way I can make a switch that ensures it will go into tv mode from any previous state.
Any advices / workarounds?
Thanks!


#75

For those struggling as I did, use the customer samsungtv_custom as posted by MrUart232 above. Then, it’s about figuring out the KEYS to send to the TV. On my model, to get to HDMI1 I need to send KEY_EXT20 (don’t ask me why KEY_HDMI1 and all others don’t work). And If I want HDMI2 or 3 I need to first send KEY_EXT20 and then KEY_HDMI a number of times to get to the right one…
Thank you Samsung for making this as bad as possible.


#77

I just switched to the latest v0.81 version of Hassio. Everything is now up and running except the samsungtv component (https://www.home-assistant.io/components/media_player.samsungtv/) It doesn’t return the correct state - neither on/off. And when it turns on it sets the state to “unknown” and then it won’t return anything for when the tv is turned off.
Is there anything I can do to make it work again?


#78

I was having similar issues. The built-in samsungtv component didn’t do much other than turn on the TV. Off didn’t work.

I tried the custom file at the top of this thread and that didn’t work either. I then found a newer version on:

That worked.

I’m using WIFI and this within the configuration.yaml file:

media_player:

  • platform: samsungtv
    host:
    mac:
    port: 8001
    timeout: 5
    name: Samsung TV

Now I can turn on/off and change the volume. I’ll try the custom KEYS next and see what I can control.

Hope that helps someone.


#79

Quick update that the script with the KEY CODES works perfectly.

I found that various supported codes in:

/home/homeassistant/homeassistant/lib/python3.6/site-packages/samsungctl/interactive.py and added those to a custom button card in lovelace as follows:

  - type: vertical-stack
    title: Samsung TV
    cards:
    - type: horizontal-stack  
      cards:
        - type: "custom:button-card"
          color_type: blank-card
        - type: "custom:button-card"
          color_type: card
          color: rgb(223, 255, 97)
          icon: mdi:power-off
          action: service
          service:
            domain: media_player
            action: send_key
            data:
              entity_id: media_player.samsung_tv
              key_code: 'KEY_POWER'
        - type: "custom:button-card"
          color_type: blank-card
        - type: "custom:button-card"
          color_type: card
          color: rgb(223, 255, 97)
          icon: mdi:power
          action: service
          service:
            domain: media_player
            action: turn_on
            data:
              entity_id: media_player.samsung_tv
        - type: "custom:button-card"
          color_type: blank-card

The outcome is as follows (I’ve yet to style it so it’s a little “bright”!! But it works great and controls everything I need on the Samsung TV.

Simple.


#80

Hi @chrisaxe21, do you have the full code for the rest of the buttons?
I copied what was there and I only have the send and power button displaying.


#81

@wills106

FYI:

_mappings = [
[“p”, “KEY_POWEROFF”, “P”, “Power off”],
[“KEY_UP”, “KEY_UP”, “Up”, “Up”],
[“KEY_DOWN”, “KEY_DOWN”, “Down”, “Down”],
[“KEY_LEFT”, “KEY_LEFT”, “Left”, “Left”],
[“KEY_RIGHT”, “KEY_RIGHT”, “Right”, “Right”],
[“KEY_PPAGE”, “KEY_CHUP”, “Page Up”, “P Up”],
[“KEY_NPAGE”, “KEY_CHDOWN”, “Page Down”, “P Down”],
["\n", “KEY_ENTER”, “Enter”, “Enter”],
[“KEY_BACKSPACE”, “KEY_RETURN”, “Backspace”, “Return”],
[“q”, “KEY_EXIT”, “Q”, “Exit”],
[“h”, “KEY_CONTENTS”, “H”, “Smart Hub”],
[“l”, “KEY_CH_LIST”, “L”, “Channel List”],
[“m”, “KEY_MENU”, “M”, “Menu”],
[“s”, “KEY_SOURCE”, “S”, “Source”],
[“g”, “KEY_GUIDE”, “G”, “Guide”],
[“t”, “KEY_TOOLS”, “T”, “Tools”],
[“i”, “KEY_INFO”, “I”, “Info”],
[“z”, “KEY_RED”, “Z”, “A / Red”],
[“x”, “KEY_GREEN”, “X”, “B / Green”],
[“c”, “KEY_YELLOW”, “C”, “C / Yellow”],
[“v”, “KEY_BLUE”, “V”, “D / Blue”],
[“d”, “KEY_PANNEL_CHDOWN”, “D”, “3D”],
["+", “KEY_VOLUP”, “+”, “Volume Up”],
["-", “KEY_VOLDOWN”, “-”, “Volume Down”],
["", “KEY_MUTE”, "", “Mute”],
[“0”, “KEY_0”, “0”, “0”],
[“1”, “KEY_1”, “1”, “1”],
[“2”, “KEY_2”, “2”, “2”],
[“3”, “KEY_3”, “3”, “3”],
[“4”, “KEY_4”, “4”, “4”],
[“5”, “KEY_5”, “5”, “5”],
[“6”, “KEY_6”, “6”, “6”],
[“7”, “KEY_7”, “7”, “7”],
[“8”, “KEY_8”, “8”, “8”],
[“9”, “KEY_9”, “9”, “9”],
[“KEY_F(1)”, “KEY_DTV”, “F1”, “TV Source”],
[“KEY_F(2)”, “KEY_HDMI”, “F2”, “HDMI Source”],
]


#82

This was broken from this commit: https://github.com/dapowers87/home-assistant/commit/1cbb5b8e51e849dfa37185fc133c599170196ec0#diff-a43590df2ca31e1387a03c586a5a56aa

I changed it back from None to STATE_ON and it went back to saying On again. The reason the developer did this was because the media player would hide the Play/Pause button if it was in STATE_ON

I am attempting to revert the change.