Samsung Smart TV (on or off)

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: Samsung Smart TV (on or off)

Post by pj-r »

Far as I know in the older models the network chip is unpowered while in standby so it cannot be turned on from network.

Has anyone used(or tried to use) HDMI-CEC to turn on samsung tv? I'm wondering if should I use IR-blaster or HDMI-CEC for that task.
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
Hesmink
Posts: 168
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by Hesmink »

pj-r wrote:Far as I know in the older models the network chip is unpowered while in standby so it cannot be turned on from network.

Has anyone used(or tried to use) HDMI-CEC to turn on samsung tv? I'm wondering if should I use IR-blaster or HDMI-CEC for that task.
I can confirm you cannot turn on a Samsung TV via network.
I don't know about your other solutions, I haven't tried.
kurniawan77
Posts: 46
Joined: Wednesday 21 January 2015 20:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by kurniawan77 »

Hesmink wrote:
proohu01 wrote:What is the exact line you entered in the 'off action' field?
And can you share you script?
The off action is:
script://domoticz/scripts/samsung_tv_off.py

The script is a slightly modified version of something I found on the internet:

Code: Select all

#!  /usr/bin/python
#   Title: samsungremote.py
#   Author: Asif Iqbal
#   Date: 05APR2012
#   Info: To send remote control commands to the Samsung tv over LAN
#   TODO:

import socket
import base64
import time, datetime

#
# Variables
#
#IP Address of TV
tvip = "192.168.178.16"
#IP Address of TV
myip = "192.168.178.14"
#Used for the access control/validation, but not after that AFAIK
mymac = "b8-27-eb-f1-5a-f3"
#Might need changing to match your TV type
tvappstring = "iphone.UE46ES8000.iapp.samsung"
#What gets reported when it asks for permission
remotename = "Domoticz Samsung Remote"

#What the iPhone app reports (don't change this)
appstring = "iphone..iapp.samsung"

# Function to send keys
def sendKey(skey, dataSock, appstring):
 messagepart3 = chr(0x00) + chr(0x00) + chr(0x00) + chr(len(
base64.b64encode(skey))) + chr(0x00) + base64.b64encode(skey);
 part3 = chr(0x00) + chr(len(appstring)) + chr(0x00) \
+ appstring + chr(len(messagepart3)) + chr(0x00) + messagepart3
 dataSock.send(part3);

# Open Socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((tvip, 55000))

# First configure the connection
ipencoded = base64.b64encode(myip)
macencoded = base64.b64encode(mymac)
messagepart1 = chr(0x64) + chr(0x00) + chr(len(ipencoded)) \
+ chr(0x00) + ipencoded + chr(len(macencoded)) + chr(0x00) \
+ macencoded + chr(len(base64.b64encode(remotename))) + chr(0x00) \
+ base64.b64encode(remotename)

part1 = chr(0x00) + chr(len(appstring)) + chr(0x00) + appstring \
+ chr(len(messagepart1)) + chr(0x00) + messagepart1
sock.send(part1)

messagepart2 = chr(0xc8) + chr(0x00)
part2 = chr(0x00) + chr(len(appstring)) + chr(0x00) + appstring \
+ chr(len(messagepart2)) + chr(0x00) + messagepart2
sock.send(part2)

# Now send the keys as you like, e.g.,
sendKey("KEY_TVPOWEROFF",sock,tvappstring)

# Close the socket when done
sock.close()
Works!!!

I had to change KEY_TVPOWEROFF to KEY_POWEROFFImage
pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: Samsung Smart TV (on or off)

Post by pj-r »

There is also a command line client if someone would like to use it:
http://forum.samygo.tv/viewtopic.php?t=5794#p41376

I have it and it works nicely.
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
d4nh
Posts: 5
Joined: Friday 30 January 2015 16:53
Target OS: Linux
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by d4nh »

kurniawan77 wrote:
Works!!!

I had to change KEY_TVPOWEROFF to KEY_POWEROFFImage
indeed, nice find, had to change it as well. i dont think my presence detection is working very well, it turns off my tv everytime xD
brian
Posts: 5
Joined: Saturday 04 April 2015 18:04
Target OS: Linux
Domoticz version: beta
Location: Italy
Contact:

Re: Samsung Smart TV (on or off)

Post by brian »

pj-r wrote: Has anyone used(or tried to use) HDMI-CEC to turn on samsung tv? I'm wondering if should I use IR-blaster or HDMI-CEC for that task.
i'm using an RPi2 turned on via an SNMP script (PoE switch + TP-Link PoE splitter), CEC commands works flawlessly
treb0r
Posts: 10
Joined: Friday 19 June 2015 13:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by treb0r »

Hesmink wrote:

Second, use the python script in this topic (samsungremote.py), and substitute your tv IP address in the script.

Then, use the script as 'off' action for your TV switch:
script:///home/pi/domoticz/scripts/samsung_tv_off.py
I have a quetion to this part of the script

Code: Select all

#IP Address of TV
tvip = "192.168.178.16"
#IP Address of TV
myip = "192.168.178.14"
#Used for the access control/validation, but not after that AFAIK
mymac = "b8-27-eb-f1-5a-f3"
tvip: TV IP abviouse ;)
myip: IP of domoticz server?
mymac: MAC of domoticz server?
thanks
treb0r
Hesmink
Posts: 168
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by Hesmink »

treb0r wrote:
Hesmink wrote:

Second, use the python script in this topic (samsungremote.py), and substitute your tv IP address in the script.

Then, use the script as 'off' action for your TV switch:
script:///home/pi/domoticz/scripts/samsung_tv_off.py
I have a quetion to this part of the script

Code: Select all

#IP Address of TV
tvip = "192.168.178.16"
#IP Address of TV
myip = "192.168.178.14"
#Used for the access control/validation, but not after that AFAIK
mymac = "b8-27-eb-f1-5a-f3"
tvip: TV IP abviouse ;)
myip: IP of domoticz server?
mymac: MAC of domoticz server?
thanks
treb0r
Yes, that is correct.
User avatar
thecosmicgate
Posts: 188
Joined: Monday 06 April 2015 14:37
Target OS: Linux
Domoticz version: newest
Location: The Netherlands / Hoeven
Contact:

Re: Samsung Smart TV (on or off)

Post by thecosmicgate »

Is there anybody who got this working on a Samsung UE65HU7500 ?

I tried this pyhton scipt but getting : returned: 32512 everytime
It's nice to be important, but it's more important to be nice
Scooter ;)
User avatar
thecosmicgate
Posts: 188
Joined: Monday 06 April 2015 14:37
Target OS: Linux
Domoticz version: newest
Location: The Netherlands / Hoeven
Contact:

Re: Samsung Smart TV (on or off)

Post by thecosmicgate »

Is there nobody who also try to run this on the hu7500 series ?

Sent from my MotoG3 using Tapatalk
It's nice to be important, but it's more important to be nice
Scooter ;)
User avatar
thecosmicgate
Posts: 188
Joined: Monday 06 April 2015 14:37
Target OS: Linux
Domoticz version: newest
Location: The Netherlands / Hoeven
Contact:

Re: Samsung Smart TV (on or off)

Post by thecosmicgate »

Still nobody ?
It would be very handy , but if it isn't possible then I had to think about something else to shutdown this TV using domoticz
It's nice to be important, but it's more important to be nice
Scooter ;)
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Samsung Smart TV (on or off)

Post by mvzut »

As an alternative solution: If you can spare the money, I can highly recommend a Logitech Harmony remote. The hub can be connected to Domoticz, so that you will always know in which state your TV is, and you can also switch it off and even on.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
User avatar
proohu01
Posts: 95
Joined: Friday 17 October 2014 12:20
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by proohu01 »

I used the Domoticz build-in "System Alive Checker (Ping)" to determine if my Samsung TV's are on or off. However, last week my EU40H6200 got a firmware update. Since then, it always replies to a ping. Even when the TV is turned off.

I did an nmap to check for ports that might be used to find a new way of getting the power state of this TV. These ports seem to be open:
ports
ports
samsung ports.JPG (29.09 KiB) Viewed 24887 times
So I don't want to control the TV. I just want to be able to determine the power state without having to buy a power plug with energy usage reporting capabilities. Is there a simple way? I am not a programmer but could this node.js express framework (port 8001) be of any use?
Pi 2 B | Pi Camera | PiFace 2 | RFXtrx433E (KaKu + Oregon Scientific) | Plugwise (9 Circles) | Aeon Z-Wave stick (Fibaro - dimmers, sockets, RGB, screens/blinds) | RFXMeter (Kwh/water/gaz) | WOL | Onkyo Receiver | RTC | Hikvision | Netatmo | Satel Integra
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Samsung Smart TV (on or off)

Post by juankar »

It doesn't wor with UE48H6500 (api ver 2.0) model of 2014. :(
Ah! it has not 55000 port open, it has 15500, but it doesn't obey commands...
wokkelp
Posts: 24
Joined: Monday 24 August 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by wokkelp »

Hesmink wrote:
proohu01 wrote:What is the exact line you entered in the 'off action' field?
And can you share you script?
The off action is:
script://domoticz/scripts/samsung_tv_off.py

The script is a slightly modified version of something I found on the internet:

Code: Select all

#!  /usr/bin/python
#   Title: samsungremote.py
#   Author: Asif Iqbal
#   Date: 05APR2012
#   Info: To send remote control commands to the Samsung tv over LAN
#   TODO:

import socket
import base64
import time, datetime

#
# Variables
#
#IP Address of TV
tvip = "192.168.178.16"
#IP Address of TV
myip = "192.168.178.14"
#Used for the access control/validation, but not after that AFAIK
mymac = "b8-27-eb-f1-5a-f3"
#Might need changing to match your TV type
tvappstring = "iphone.UE46ES8000.iapp.samsung"
#What gets reported when it asks for permission
remotename = "Domoticz Samsung Remote"

#What the iPhone app reports (don't change this)
appstring = "iphone..iapp.samsung"

# Function to send keys
def sendKey(skey, dataSock, appstring):
 messagepart3 = chr(0x00) + chr(0x00) + chr(0x00) + chr(len(
base64.b64encode(skey))) + chr(0x00) + base64.b64encode(skey);
 part3 = chr(0x00) + chr(len(appstring)) + chr(0x00) \
+ appstring + chr(len(messagepart3)) + chr(0x00) + messagepart3
 dataSock.send(part3);

# Open Socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((tvip, 55000))

# First configure the connection
ipencoded = base64.b64encode(myip)
macencoded = base64.b64encode(mymac)
messagepart1 = chr(0x64) + chr(0x00) + chr(len(ipencoded)) \
+ chr(0x00) + ipencoded + chr(len(macencoded)) + chr(0x00) \
+ macencoded + chr(len(base64.b64encode(remotename))) + chr(0x00) \
+ base64.b64encode(remotename)

part1 = chr(0x00) + chr(len(appstring)) + chr(0x00) + appstring \
+ chr(len(messagepart1)) + chr(0x00) + messagepart1
sock.send(part1)

messagepart2 = chr(0xc8) + chr(0x00)
part2 = chr(0x00) + chr(len(appstring)) + chr(0x00) + appstring \
+ chr(len(messagepart2)) + chr(0x00) + messagepart2
sock.send(part2)

# Now send the keys as you like, e.g.,
sendKey("KEY_TVPOWEROFF",sock,tvappstring)

# Close the socket when done
sock.close()
Steps I took:
I copied your script to the scripts folder on my Raspberry Pi;
I changed tvip to the ip address of my Samsung smart TV;
I changed myip to the ip address of my Raspberry Pi;
I changed mymac to the mac address of my Raspberry Pi;
I changed tvappstring to iphone.UE40F6600.iapp.samsung;
I created a virtual switch with the script:// line in the off action.

It doesn't work, my domoticz log doesn't show any errors and my TV doesn't ask for permission or responds to the command sent from the script.
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: Samsung Smart TV (on or off)

Post by Treve »

I use a simpler way to achieve this.

i own a Samsung UE40H6620SV SmartTV and detect by Network if the Samsung is on or of. It also works when Samsung is in standby mode.
I use this to prevent the lights go off when i watch late television, it works perfect.

1 - i installed new hardware type "System Alive Checker" (ping)

2 - I'm attaching the IP Address of the Samsung to "settings"

3 - Result is a virtual switch



When i try to add images as an example, i get the message "Sorry, the board attachment quota has been reached".
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
nigels0
Posts: 221
Joined: Thursday 23 January 2014 12:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Samsung Smart TV (on or off)

Post by nigels0 »

Newer Samsung TVs ( >2014) have a different protocol and the 55000 port is not available any more.
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Samsung Smart TV (on or off)

Post by bigpea »

Hi all,
i'm trying to use this script, but I have one question, for my curiousity:.
What does it mean the string:

Code: Select all

tvappstring = "iphone.UE46ES8000.iapp.samsung"
I tknow that the UE46ES8000 is the model of the TV, "samsung" is the brand (iphone and iapp I don't know), but in practice what they do?

Thanks. :)
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

it is used in authentication with the tv.
Change it to something else and you will see a popup on your tv, asking if you want to add this new remote.
And you have to accept it on the tv...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest