Samsung TV K Series - OH2 with exec binding and python3, TV Control -question setting TV volume like Setpoint, Rollershuter

Hi,
I need to control TV volume level by sending exec command of Setpoint item
if arrow up is pressed:
executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLUP")

if arrow down is pressed command volume level down should be executed:
executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLDOWN")

How should I define such an “Setpoint Item” and how should be defined rule.
Thanks.

If there is a command line tool for this, how hard would it be to update the openHAB2 binding to support newer TVs?

I found a solution in Domoticz forum and it works for Openhab with exec binding :0)
for new Samsung TV. I have 65KS7500 Type and it works on Tizen.
https://www.domoticz.com/wiki/Plugins/SamsungTV.html

You need install samsungctl:

From pi cmd line install:
pip3 install samsungctl
pip3 install websocket-client (necessary for new TVs.

After this copy modified samsungtv.conf to pi/.config directory
{
“name”: “samsungctl”,
“description”: “Pi”,
“id”: “”,
“method”: “websocket”,
“port”: 55000,
“timeout”: 0
}

After this you can start using a command line like:
/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_xxxx
Try /usr/local/bin/samsungctl -i --host 192.168.100.200 --method websocket
for all possible commands :0)

Define rules:
rule “Samsung TV Pwr Toogle”
when
Item TV_Pwr received command
then
if(receivedCommand == OFF) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_POWER")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_POWER")
end

rule “Samsung TV Volume Up/Down”
when
Item TV_VolUpDown received update
then
if(receivedCommand == OFF) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLDOWN")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLUP")
end

rule “Samsung TV Volume Mute”
when
Item TV_Mute received command
then
if(receivedCommand == OFF) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLUP")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_MUTE")
end

!!! On first connection with TV you must confirm pairing. Python program simulates Samsung Remote Control unit

My question is about control volume Up and Down with Openhab item/rule like setpoint with arrows.
If you able please rename post to Samsung new type TV control in Openhab2.

rule “Samsung TV Volume Up/Down"
when
Item TV_VolUpDown received update
then
if(receivedCommand == OFF) executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLDOWN")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.200 --method websocket KEY_VOLUP")
end

This is not usable :0(

If you prefer contact me on Skype jozefszabo from Bratislava (German or english or slovak)

Hi,
Maybe coincidence. This is what I posted today:

Maybe it helps.
Cheers

Installation

  1. Install python3-pip:

Code: Select all
sudo apt-get install python3-pip

  1. Install SamsungCTL:

Code: Select all
sudo pip3 install samsungctl

  1. Install websocket-client (this python module is needed for the 2016+ Samsung models):

Code: Select all
sudo pip3 install websocket-client

  1. Make sure your TV is on, run the following command from the cli (Change xxx.xxx.xxx.xxx with the IP address of your TV):

Code: Select all
samsungctl --host xxx.xxx.xxx.xxx --method websocket KEY_MUTE

Info about possible KEYs
samsungctl -i --host xxx.xxx.xxx.xxx --method websocket

Does this work for you? Once I turn the TV off I can’t turn it back on because the connection is dead. Thinking I may have to setup WOL for on.

P.S. Can you share your sitemap?

Hi.
Wol is functioning ok, but also the rule. It switch between power on and off. I will share sitemap.

Hi,
Prepare all as descibed in the installation above.

On sitemap I have only a group for Dreambox and Samsung
Frame {
Group item=DM8000 label=“DM8000” icon="receiver"
Group item=Samsung label=“Samsung” icon=“television”
}

Rules
rule “Samsung TV Pwr Toogle"
when
Item TV_Power received command
then
if(receivedCommand == OFF) executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_POWER")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_POWER")
end

rule “Samsung TV Volume Up"
when
Item TV_VolUp received update
then
executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_VOLUP")
end

rule “Samsung TV Volume Down"
when
Item TV_VolDown received update
then
executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_VOLDOWN")
end

rule “Samsung TV Volume Mute"
when
Item TV_Mute received command
then
if(receivedCommand == OFF) executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_VOLUP")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_MUTE")
end

Items
/* Samsung python3 - UE65KS7950 */
Switch TV_Power “Samsung” ( Samsung ) [ “Lighting” ]
Switch TV_VolUp “Samsung Up” ( Samsung ) [ “Lighting” ]
Switch TV_VolDown “Samsung Down” ( Samsung ) [ “Lighting” ]
Switch TV_Mute “Samsung Audio” ( Samsung ) [ “Lighting” ]

TV must be on Stanby mode “under voltage”

Neked hogz sikerult?

Igen Krisztian.
Kérjük, olvassa el németül angol slovak

Az baj hogy végig mentem mindenen
de nem akarja

Nem beszélek magyarről, amikor szabó vagyok

okay sorry my openhab raspberry and samsung tv ue48h6400

1 add binding system
power ok :slight_smile:
mute ok :slight_smile:
channel not ok

Pls help me

phyton add okay
samsungctl add okay

command this
samsungctl --i 192.168.100.115 --host – --method websocket KEY_VOLUP
not working
"error: operation now in progress"

rule “Samsung TV Pwr Toogle"
when
Item TV_Power received command
then
if(receivedCommand == OFF) executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_POWER")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_POWER")
end

rule "Samsung TV Volume Up"
when
Item TV_VolUp received update
then
executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_VOLUP")
end

rule “Samsung TV Volume Down"
when
Item TV_VolDown received update
then
executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_VOLDOWN")
end

rule “Samsung TV Volume Mute"
when
Item TV_Mute received command
then
if(receivedCommand == OFF) executeCommandLine(”/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_VOLUP")
if(receivedCommand == ON) executeCommandLine("/usr/local/bin/samsungctl --host 192.168.100.110 --method websocket KEY_MUTE")
end

Hi,

Did you cover a problem with going offline TV? Are you able to power on? I have version M (2017) and I can perform commands. I’ve noticed some strange behavior - I’ve added a POWER key with binding OH2 and I can read ON/OFF status (switch value updates), but I can’t send anything.

Hi, I switched to Raspbian stretch and all is not working :0(

samsungctl -i --host xx.xx.xx.xx --method websocket
Error: Operation now in progress

This is something with python3.4 versus 3.5 or
samsungctl 0.6.0 versus 0.7.0 or
websocket-client 0.44 versus 0.4 versions.

http://xx.xx.xx.xx:8001/api/v2/ shows

id “uuid:bf5570d7-c84e-445a-983e-671c3775de28”
name “[TV] Samsung 7 Series (65)”
version “2.1.0”
device
type “Samsung SmartTV”
duid “uuid:bf5570d7-c84e-445a-983e-671c3775de28”
model “16_JAZZM_UHD”
modelName “UE65KS7590”
description “Samsung DTV RCR”
networkType “wireless”
ssid “c0:3f:0e:7a:8c:a8”
ip “xx.xx.xx.xx”
firmwareVersion “Unknown”
name “[TV] Samsung 7 Series (65)”
id “uuid:bf5570d7-c84e-445a-983e-671c3775de28”
udn “uuid:bf5570d7-c84e-445a-983e-671c3775de28”
resolution “3840x2160”
countryCode “SK”
msfVersion “2.1.0”
smartHubAgreement “true”
VoiceSupport “true”
GamePadSupport “true”
wifiMac “xx:xx:xx:xx:xx:xx”
developerMode “0”
developerIP “”
OS “Tizen”
type “Samsung SmartTV”
uri “http://xx.xx.xx.xx:8001/api/v2/
remote “1.0”
isSupport “{“remote_available”:“true”,“remote_fourDirections”:“true”,“remote_touchPad”:“true”,“remote_voiceControl”:“true”,“DMP_available”:“true”,“DMP_DRM_PLAYREADY”:“false”,“DMP_DRM_WIDEVINE”:“false”,“EDEN_available”:“true”}”

I copied python3.4 dist-packages to new python3.5 and it is working !?!?!

And also toogle TV power on/off in standby mode is correct.
Don’t forget switch off the authentification from new connections via wifi.

Mary chrismas.

Is it possible to read somehow state of source - e.g. if it’s HDMI1 or HDMI2 ?

HI, look at table from 2.April. They are two functions, maybe one is equivalent of display sources on TV and another for info? But I have not tryed it. Good luck.
KEY_SOURCE
KEY_HDMI

Unfortunately not…HDMI changes source and SOURCE shows all sources on TV… maybe any http request ?
I found: http://XXXXXX:8001/api/v2/ - but there is no info about it.