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

User avatar
proohu01
Posts: 95
Joined: Friday 17 October 2014 12:20
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Samsung Smart TV (on or off)

Post by proohu01 »

Does anyone know, whether or not it is possible to detect if a Samsung Smart TV is turned on or off using the network connection?
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
[email protected]
Posts: 14
Joined: Sunday 31 August 2014 15:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by [email protected] »

Probably "YES". My TV (old one now) will not respond to a "ping" when it is in standby, but WILL respond when "on". You can use a script to ping the TV occasionally and to set the state of a dummy switch. This is described in a separate part of the wiki under "presence detection". The script is called something like "check_device_online.py". You would need to modify this for your TV's IP address (I assume it is static?) and to start a CRON job which runs this script every hour. I have this script running to ping a mobile phone.
Last edited by [email protected] on Monday 22 December 2014 19:15, edited 1 time in total.
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 »

Thnx for the reply.
I already use the ping script for some other devices so I am familiar with that. I also own an Onkio receiver and that has a very cool (linux) command line tool that can control almost any function and also query the power state. That's (in my opinion) a more intelligent approach than a ping so I was hoping to accomplish the same functionality with my Samsung TV's.
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
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by ThinkPad »

Maybe start with telling us the type of TV you have ;)
I am not active on this forum anymore.
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by roblom »

Tested it, and it works on my Samsung TV that is connected to the internet.
[email protected]
Posts: 14
Joined: Sunday 31 August 2014 15:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by [email protected] »

Understood about the intelligent query - much better solution if available. My old (series 6) Samsung does not appear to expose a web-page or a command-line interface. I don't think (?) it has any SNMP functionality either, but that might be worth a check? This is outside my (current) expertise... One other thought: my TV is plugged into a Z-wave switched socket with a power metering function (to provide the ultimate "off" control!). I can easily see if the TV is on (about 70 Watts) or in standby (about 5 watts) using the switch data.
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 »

Haha Tony, you keep telling me stuff I already use :lol: ;) I use a Plugwise circle to monitor the power usage and a LUA script to switch the LED lights (Fibaro RGBW z-wave controller) behind the TV on or off automatically based on the power usage. So all is working. Wel, most off the time anyway. Sometimes the powerusage is not returned. Probably has something to do with the range op my Plugwise network.

It's just that there are APP's for your Android and iPhone that can controle certain aspects of the TV. If an APP can do that, why not Domoticz. At least, that was my way of thinking.
Btw, I have a UE40H6200 and a UE55F8000
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
User avatar
tommit01
Posts: 39
Joined: Friday 12 July 2013 14:08
Target OS: Raspberry Pi / ODroid
Domoticz version: multiple
Location: Germany / SL
Contact:

Re: Samsung Smart TV (on or off)

Post by tommit01 »

Just have a look..

Think there should also be a REST API

http://www.samsungdforum.com/Guide/
1 x RPi3
4 x RPI
3 x RPi2
1 x RPI2 + Win 10 IoT (experimental device)
2 x RPI2 Raspbian "Jessie" + Domoticz (for tenants)
2 x RPI OSMC @ 1GHz
1 RPi Zero W + Cam NOIR
1 RPi Zero W + Cam
RFXtrx 433 FW 1015
RFXtrx 433 E FW 1020
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Samsung Smart TV (on or off)

Post by pvm »

Possibly more information by Samsung, this needs some development...

And just for fun, sending commands to TV can be done from LUA, see this
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
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 »

pvm wrote:Possibly more information by Samsung, this needs some development...

And just for fun, sending commands to TV can be done from LUA, see this
Thnx. I will give this a go...
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
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Samsung Smart TV (on or off)

Post by pvm »

Keep us posted, it would be nice to see webcam in dual screen view when doorbel rings, or things like that
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by mlamie »

Something like http://youtu.be/5uvGQ8TuWBg

That seems quite interesting.
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
frostwork
Posts: 5
Joined: Friday 14 November 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by frostwork »

the samsung remote sourcecode posted here might help:
http://forum.samygo.tv/viewtopic.php?f=12&t=5794
there doesn't seem to be a license though

it worked very fine on my samsungtv, but I decided that I do not want my tv to be in the network and thererfore control it via harmonyhub instead.
maybe also worth to mention that several (all?) samsung tvs can't be turned on via wol, as the network has no power when the tv is turned off.
Hesmink
Posts: 168
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Samsung Smart TV (on or off)

Post by Hesmink »

Hi,

I'm checking if my Samsung TV is on or off using ping.
Since I'm using a dummy light switch for this, I thought it would be nice to be able to turn the tv off by clicking on the switch icon.

I have a working python script that turns the tv off. Can I use this as an 'off action' for the switch?
I tried, but it doesn't work. The python scripts works fine from the command line. Are script actions logged somewhere?
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 »

What is the exact line you entered in the 'off action' field?
And can you share you script?
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
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 »

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()
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 presume that the Python file is executable for your pi user?
Have you tried this: "script:///home/pi/domoticz/scripts/samsung_tv_off.py"

I will try this script myself tonight.
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
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 »

proohu01 wrote:I presume that the Python file is executable for your pi user?
Have you tried this: "script:///home/pi/domoticz/scripts/samsung_tv_off.py"

I will try this script myself tonight.
Yes! That works!

I also made the mistake to change the TV type to my own, but somehow that broke the script.
I changed the line back to:
tvappstring = "iphone.UE55C8000.iapp.samsung"
and using your full path, fixed it.

I'll probably never use is, but now I can turn my tv off using Domiticz 8-)
CalvinTy
Posts: 1
Joined: Monday 20 January 2014 6:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by CalvinTy »

Ok, I am an absolute beginner here. Can you guide us step by step exactly what we need to do to interface with the Samsung TV and execute the command please? Hopefully, when I understand how to do this properly, I can actually contribute back to the community.
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 »

CalvinTy wrote:Ok, I am an absolute beginner here. Can you guide us step by step exactly what we need to do to interface with the Samsung TV and execute the command please? Hopefully, when I understand how to do this properly, I can actually contribute back to the community.
First create a dummy switch for your TV, and ping it to know if it's on.
You can find how to do that in the wiki: http://www.domoticz.com/wiki/Presence_detection

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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests