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

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 »

ohh i undesrtood! :)
Thanks for your reply.
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 »

Ok, i created my script but It doesn't work.
Domoticz doesn't log any errors and my TV doesn't ask for permission and not responds to the command sent from the script.
I use port 55000, if i use differenti port i receive an error: Connection refused.
So o think the porr os correct.
Any idea?

Thanks.
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

* Check the "settings" of the tv about the "wireless remote control", if it accepts request... (i think 4 is the limit, if you already used that up...)

* Your model is too new and the changed the api.

* Do you use the code on the wiki? (https://www.domoticz.com/wiki/Samsung_TV)? or the above code... script?
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, thanks for your reply.
* Check the "settings" of the tv about the "wireless remote control", if it accepts request... (i think 4 is the limit, if you already used that up...)
I don't see this option on my tv.. it isn'r present.
* Your model is too new and the changed the api.
How can I check this information?
* Do you use the code on the wiki? ( https://www.domoticz.com/wiki/Samsung_TV )? or the above code... script?
No I'm using the code found in this topic:

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()
I will try with the code on your link. Thanks.
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 »

Ok,
i trying to use the script in your link.

I created in the domoticz/scripts folder these files:

popup.sh

Code: Select all

STVCLI $1 -SMS "" "" "" "" "" "" $2
SLEEP 0.3
STVCLI $1 -KEY KEY_ENTER
SLEEP 3
STVCLI $1 -KEY KEY_ENTER
stvcli.c

Code: Select all

/*
* SamsungTV Remote C++ Command Line Interface v0.02 April 2013 TRiXWooD (cris.wood.org -AD- ‪gmail.com‬)
*
* Network Error Handling (Mostly Missing)
* Key &| Text Input Checking, some chars will result in disabling the tv's remote part
*
* April 2013
* v0.00 Prototype
* v0.01 Remote Working
* v0.02 SOAP Message Working
*
*
* modified base64 (Base64EncodeDecode.c) from Sam Ernest Kumar 
* part code/research from various places/people on the samygo forum
*/
 
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>
 
 
int samsungtv_base64encodeblock(char *input, char *output, int oplen){
  int rc = 0, iplen = 0;
  char encodedstr[5] = "";
  char encodingtabe[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  iplen = strlen(input);
  encodedstr[0] = encodingtabe[ input[0] >> 2 ];
  encodedstr[1] = encodingtabe[ ((input[0] & 0x03) << 4) | ((input[1] & 0xf0) >> 4) ];
  encodedstr[2] = (iplen > 1 ? encodingtabe[ ((input[1] & 0x0f) << 2) | ((input[2] & 0xc0) >> 6) ] : '=');
  encodedstr[3] = (iplen > 2 ? encodingtabe[ input[2] & 0x3f ] : '=');
  strncat(output, encodedstr, oplen-strlen(output));  
  return rc;
}
 
int samsungtv_base64encode(char *input, char *output, int oplen){
  int rc = 0;
  int index = 0, ipindex = 0, iplen = 0;
  char encoderinput[4] = "";
  iplen = strlen(input);
  while(ipindex < iplen){
    for(index = 0; index < 3; index++){
      if(ipindex < iplen){
        encoderinput[index] = input[ipindex];
      }else{
        encoderinput[index] = 0;
      }
      ipindex++;
    }
    rc = samsungtv_base64encodeblock(encoderinput, output, oplen);
  }
  return rc;
}
 
int samsungtv_response(int net_socket) {
 unsigned char message[256];
 memset (message,0x00,256);
 int i = 3;
 recv(net_socket,message,3,0);
 recv(net_socket,message+i,message[1],0);
 i += message[1];
 recv(net_socket,message+i,2,0);
 i += 2;
 unsigned char response = message[i-2];
 recv(net_socket,message+i,response,0);
 i += response;
 if (message[i-4] == 0x00 && message[i-3] == 0x00 && message[i-2] == 0x00 && message[i-1] == 0x00)
   if (message[0] == 0x01) return 4;           // success repeat keystroke...
   else return 0;                     // success
 if (message[i-response] == 0x65) return 3;         // timeoutt....
 if (message[i-4] == 0x64 && message[i-2] == 0x00) return 1; // access denied...
 if (message[i-4] == 0x64 && message[i-2] == 0x01) return 0; // success
 if (message[i-response] == 0x0A) return 2;         // waiting for user...
 return -1;                         // bug!
}
 
int samsungtv_setlength(unsigned char message[], unsigned int length) {
  message[0] = (unsigned char) (length & 0xFF);
  message[1] = (unsigned char) ((length >> 8) & 0xFF);
}
 
int samsungtv_setstring(unsigned char message[],unsigned char string[],int base64) {
  unsigned char s[512];
  memset (s,0x00,512);
  if (base64 == 1) samsungtv_base64encode(string,s,strlen(string)*2);
  else strncpy(s,string,strlen(string));
  samsungtv_setlength(message,strlen(s));
  strncpy(message+2,s,strlen(s));
  return strlen(s)+2;
}
 
enum modes {eKey, eText, eSMS, eCall, eSchedule, eAuth, eUnknown};
 
int samsungtv_message(unsigned char string[], int net_socket,int type) {
  unsigned char remote[] = "SamsungTVRemote";
  unsigned char message[1024];
  memset (message,0x00,1024);
  unsigned int s = samsungtv_setstring(message+1,"iphone.iapp.samsung",0) + 1;
  unsigned int i = s + 4 + (type==eKey?1:0);
  i += samsungtv_setstring(message+i,string,1);
  if (type == eAuth) {
    message[s+2] = 0x64;
    i += samsungtv_setstring(message+i,remote,1);
    i += samsungtv_setstring(message+i,remote,1);
  }
  if (type == eText) {
   message[0] = 0x01;
   message[s+2] = 0x01;
  }
  samsungtv_setlength(message+s,i-s-2);
  send(net_socket,message, i, 0);
  return (type==eText?0:samsungtv_response(net_socket));
}
 
int samsungtv_authenticate(unsigned char ip[], int net_socket) { return samsungtv_message(ip,net_socket,eAuth); }
int samsungtv_key(unsigned char key[], int net_socket) { return samsungtv_message(key,net_socket,eKey); }
int samsungtv_text(unsigned char text[], int net_socket) { return samsungtv_message(text,net_socket,eText); }
 
int samsungtv_sms(char ip[], int net_socket, char date[], char time[], char from[], char fromnumber[], char to[],
         char tonumber[], char message[]) {
 char request[3072];
  sprintf( request,"<Category>SMS</Category>"
     "<DisplayType>Maximum</DisplayType>"
     "<ReceiveTime>"
     "<Date>%s</Date>"
     "<Time>%s</Time>"
     "</ReceiveTime>"
     "<Receiver>"
     "<Number>%s</Number>"
     "<Name>%s</Name>"
     "</Receiver>"
     "<Sender>"
     "<Number>%s</Number>"
     "<Name>%s</Name>"
     "</Sender>"
     "<Body>%s</Body>",date,time,tonumber,to,fromnumber,from,message);
  return samsungtv_soap(ip,net_socket,request);
}
 
int samsungtv_schedule(char ip[], int net_socket, char subject[], char startdate[], char starttime[], char enddate[], char endtime[], char location[], char owner[], char number[], char message[]) {
char request[3072];
sprintf( request,"<Category>Schedule Reminder</Category>"
"<DisplayType>Maximum</DisplayType>"
"<StartTime>"
"<Date>%s</Date>"
"<Time>%s</Time>"
"</StartTime>"
"<Owner>"
"<Number>%s</Number>"
"<Name>%s</Name>"
"</Owner>"
"<Subject>%s</Subject>"
"<EndTime>"
"<Date>%s</Date>"
"<Time>%s</Time>"
"</EndTime>"
"<Location>%s</Location>"
"<Body>%s</Body>",startdate,starttime,number,owner,subject,enddate,endtime,location,message);
 return samsungtv_soap(ip,net_socket,request);
 
}
 
int samsungtv_call(char ip[], int net_socket, char date[], char time[], char from[], char fromnumber[], char to[] , char tonumber[]) {
 
  char request[3072];
  sprintf( request,"<Category>Incoming Call</Category>"
      "<DisplayType>Maximum</DisplayType>"
      "<CallTime>"
      "<Date>%s</Date>"
      "<Time>%s</Time>"
      "</CallTime>"
      "<Callee>"
      "<Number>%s</Number>"
      "<Name>%s</Name>"
      "</Callee>"
      "<Caller>"
      "<Number>%s</Number>"
      "<Name>%s</Name>"
      "</Caller>",date,time,tonumber,to,fromnumber,from);
 
  return samsungtv_soap(ip,net_socket,request);
}
 
int samsungtv_soap(unsigned char ip[], int net_socket,char requestbody[]) {
 
  char request[3072];
  char buffer[4096];
 
  strcpy( request,
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
     "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
     "<s:Body>"
     "   <u:AddMessage xmlns:u=\"urn:samsung.com:service:MessageBoxService:1\">"
     "    <MessageType>text/xml</MessageType>"
     "    <MessageID>anything</MessageID>"
     "<Message>");
 
  strcat(request,requestbody);
  strcat(request,
     "</Message>"
     "   </u:AddMessage>"
     " </s:Body>"
     "</s:Envelope>" );
 
 sprintf( buffer,
    "POST /PMR/control/MessageBoxService HTTP/1.0\r\n"
    "Content-Type: text/xml; charset=\"utf-8\"\r\n"
    "HOST: %s\r\n"
    "Content-Length: %d\r\n"
    "SOAPACTION: \"uuid:samsung.com:service:MessageBoxService:1#AddMessage\"\r\n"
    "Connection: close\r\n"
    "\r\n", ip, strlen( request));
  strcat( buffer, request );
 
  int numbytes;
  if((numbytes = send(net_socket, buffer, strlen( buffer ), 0)) == -1) { }  
  if((numbytes = recv(net_socket, buffer, 10000, 0)) == -1) { }
}
 
int main(int argc, char *argv[]) {
 
  struct addrinfo hints, *res, *p;
  int net_status, net_socket;
   enum modes mode = eUnknown;
 
  if (argc > 2) {
    if (strcmp(argv[2],"-TEXT") == 0) mode = eText;
    if (strcmp(argv[2],"-KEY") == 0) mode = eKey;
    if (strcmp(argv[2],"-SMS") == 0) mode = eSMS;
    if (strcmp(argv[2],"-CALL") == 0) mode = eCall;
    if (strcmp(argv[2],"-SCHEDULE") == 0) mode = eSchedule;
 
  }
 
  if (argc < 4 || mode == eUnknown ||
 
    !(mode == eText && argc == 4) &&
    !(mode == eKey && argc == 4) &&
    !(mode == eSMS && argc == 10) &&
    !(mode == eCall && argc == 9) &&
    !(mode == eSchedule && argc == 12) 
 
    ) {
    printf("SamsungTV ‪Remote Control CLI‬ v0.02 April 2013 TRiXWooD\n");
    printf("usage: STVCLI IP -KEY   KEY\n");
    printf("   STVCLI IP -TEXT  TEXT\n");
    printf("   STVCLI IP -SMS   DATE TIME FROM NUMBER TO NUMBER MESSAGE\n");
    printf("   STVCLI IP -CALL  DATE TIME FROM NUMBER TO NUMBER\n");
    printf("   STVCLI IP -SCHEDULE SUBJECT STARTDATE STARTTIME ENDDATE ENDTIME LOCATION OWNER NUMBER MESSAGE\n\n");
    printf("examples: STVCLI 192.168.1.11 -KEY KEY_VOLUP\n      --Simulates Press Volume Up\n");
    printf("     STVCLI 192.168.1.11 -TEXT \"Colour Haze\"\n      --Sends Text To Youtube...\n");
    printf("     STVCLI 192.168.1.11 -SMS 2013-6-24 \"7:01:01 PM\" Cris +555-4323 Me +555-2343 \"Get Off The Couch\"\n      --Show Incomming SMS...\n");
    printf("     STVCLI 192.168.1.11 -CALL 23:06:01 Cris +555-4323 \"\" \"\"\n      --Show Incomming Call (skips input with empty strings)...\n\n\n");
    printf("exmaple script for displaying popup message\n(hint forward ports 52235 & 55000 on your internet router so you can reach your tv from anywhere)\n\nusage popup.sh 10.0.0.2 \"Pop Says The Message on C6710\"\n\nSTVCLI $1 -SMS \"\" \"\" \"\" \"\" \"\" \"\" $2\nSLEEP 0.3\nSTVCLI $1 -KEY KEY_ENTER\nSLEEP 3\nSTVCLI $1 -KEY KEY_ENTER\n");
   return 1;
  }
 
  char port[] = "55000";
  if (mode != eKey && mode != eText) strcpy(port,"52235");
 
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
  hints.ai_socktype = SOCK_STREAM;
    if ((net_status = getaddrinfo(argv[1],port, &hints, &res)) != 0) {
    fprintf(stderr, "SamsungTV Remote Control: Connection Failure: (%s)\n", gai_strerror(net_status));
    return 2;
  }
  net_socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  if ((net_status = connect(net_socket, res->ai_addr, res->ai_addrlen)) != 0) {
    fprintf(stderr, "SamsungTV Remote Control: Connected Failure (%s)\n", gai_strerror(net_status));
    return 2;
  }
 
  if (mode == eKey || mode == eText) {
   int response,auth_status = samsungtv_authenticate(argv[1],net_socket);
   if (auth_status == 0) {
    if (mode == eText) response = samsungtv_text(argv[3],net_socket);
    else response = samsungtv_key(argv[3],net_socket);
    if (response != 0 && response != 4) fprintf(stderr, "SamsungTV Remote Control: Bug!\n");
   }
   else
   { if (auth_status == -1) fprintf(stderr, "SamsungTV Remote Control: Bug!\n");
    if (auth_status == 1) fprintf(stderr, "SamsungTV Remote Control: Access Denied\n");
    if (auth_status == 2) fprintf(stderr, "SamsungTV Remote Control: Waiting On User\n");
    if (auth_status == 3) fprintf(stderr, "SamsungTV Remote Control: Time Out\n");
   }
  }
  else {
   if (mode == eSMS) samsungtv_sms(argv[1],net_socket,argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9]);
   if (mode == eCall) samsungtv_call(argv[1],net_socket,argv[3],argv[4],argv[5],argv[6],argv[7],argv[8]);
   if (mode == eSchedule) samsungtv_schedule(argv[1],net_socket,argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9],argv[10],argv[11]);
  }
  close(net_socket);
  freeaddrinfo(res);
  return 0;
}
After that i compiled with:

Code: Select all

gcc stvcli.c
But if I try to execute this command:

Code: Select all

STVCLI 192.168.1.11 -KEY KEY_VOLUP
I receive this error:

Code: Select all

-bash STVCLI command not found domoticz
Where is the error?
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

The original source was called STVCLI.c which resulted in STVCLI when compiling...
I wrote here stvcli.c resulted in stvcli :oops:

just rename the compiled file.

Code: Select all

mv stvcli STVCLI
i will update the wiki.
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 »

ok, now it works, the script finish correctly, without errors, but i don't see any message for the authorization on the tv and the tv doesn't change channel or volume.
I haven't any idea..
trixwood

Samsung Smart TV

Post by trixwood »

I have updated the command line code and it should work on a Samsung Series C, D, E and F. For those who want to script in the Samsung TV remote functions or even a notification popup,...

https://github.com/Tristan79/iSamsungTV

Working on getting the volume from upnp :-) soap, things ;)
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

Post by mlamie »

trixwood wrote:I have updated the command line code and it should work on a Samsung Series C, D, E and F. For those who want to script in the Samsung TV remote functions or even a notification popup,...

https://github.com/Tristan79/iSamsungTV

Working on getting the volume from upnp :-) soap, things ;)
@ Trixwood, I followed the Github instructions for the Raspberry Pi and my Samsung F serie tv does work when I send the command via putty as shown in the examples. Awesome :mrgreen:

P.s. I used the command "sudo mv iSamsungTV /usr/local/bin/" since with the user pi it did not work.

@bigpea, maybe you should first control the TV via an app. I expect the TV will show you a popup which asks you if you allow a remote device to control the TV. If you accept I expect the script will work as well. I use on Android TV Remote for Samsung from Spikes Labs.

Now how will I setup those commands in Domoticz? I don't get it, for example "I would like to make a on/off switch" so I created a virtual switch, but I don't understand how to make the command work.

The below does not work:
script://usr/local/bin/iSamsungTV F 192.168.1.106 -KEY KEY_POWEROFF

P.s. the KEY_POWEROFF command does work via putty, but the KEY_POWERON does not.
The following error is shown: iSamsungTV: Connected Failure (Bad value for ai_flags)
Power on via the Android app over WIFI is no issue.
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
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

The poweron, yeah I can not test that properly, since my C will go off, but when off the network is also down. I can use CEC or the remote itself but not the app. Good they changed that in the later series models :-)

I really should add better the error handling code, probably it will also not connect because I suspect the enabled wol (wake on lan) feature to put the tv on again.

Please try:

Code: Select all

nmap -p 1-65535 192.168.1.106
try it yourself when it's off and look if you get the result with port 55000, if you do its either a bug or the app uses another
new key_code which I do not have... (you could wireshark or tcpdump it)

but if you do not get any ports then I suspect they use the wol (wake up on lan) feature to turn the tv on again.

So please try it... and report back :-)

Code: Select all

apt-get install nmap
if not installed on the pi.

my output from when the tv is on

Code: Select all

pi@smarthome:~/iSamsungTV $ nmap -p 1-65535 10.0.0.92

Starting Nmap 6.47 ( http://nmap.org ) at 2016-11-17 22:14 UTC
Nmap scan report for 10.0.0.92
Host is up (0.00087s latency).
Not shown: 65531 closed ports
PORT      STATE SERVICE
5601/tcp  open  unknown
52235/tcp open  unknown
52396/tcp open  unknown
55000/tcp open  unknown

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

and when its off

[code]
pi@smarthome:~/iSamsungTV $ nmap -p 1-65535 10.0.0.92

Starting Nmap 6.47 ( http://nmap.org ) at 2016-11-17 22:14 UTC
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.36 seconds
pi@smarthome:~/iSamsungTV $ 
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

I have no idea why and I am tired... so workaround:

run this (with the correct location of your domoticz) and make sure iSamsungTV is in the /usr/local/bin

Code: Select all

sudo ln -s /usr/local/bin/iSamsungTV ~/domoticz/scripts/
it creates a link to iSamsungTV in the domoticz script folder..

leave out /usr/local/bin in the script:// thingy-me-dingy...

Code: Select all

script://iSamsungTV 10.0.0.92 -KEY KEY_VOLUP
That works...
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 »

trixwood wrote:I have no idea why and I am tired... so workaround:

run this (with the correct location of your domoticz) and make sure iSamsungTV is in the /usr/local/bin

Code: Select all

sudo ln -s /usr/local/bin/iSamsungTV ~/domoticz/scripts/
it creates a link to iSamsungTV in the domoticz script folder..

leave out /usr/local/bin in the script:// thingy-me-dingy...

Code: Select all

script://iSamsungTV 10.0.0.92 -KEY KEY_VOLUP
That works...
Indeed that works! Manny thanks. I will have a look at the other post as well.
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
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 »

See below my result. So it doesn't work when the host is down. I checked the Android app and it seams it tricks the power on command with IR instead of Wifi. I have a Samsung S6 with IR so that is the on signal even I made the app setting towards Wifi :roll:

Code: Select all

pi@raspberrypi:~$ nmap -p 1-65535 192.168.1.106

Starting Nmap 6.47 ( http://nmap.org ) at 2016-11-18 07:53 CET
Nmap scan report for 192.168.1.106
Host is up (0.018s latency).
Not shown: 65527 closed ports
PORT      STATE    SERVICE
80/tcp    open     http
443/tcp   open     https
4443/tcp  open     pharos
6000/tcp  filtered X11
7676/tcp  open     imqbrokerd
9080/tcp  open     glrpc
55000/tcp open     unknown
55001/tcp open     unknown

Nmap done: 1 IP address (1 host up) scanned in 78.66 seconds
pi@raspberrypi:~$ nmap -p 1-65535 192.168.1.106

Starting Nmap 6.47 ( http://nmap.org ) at 2016-11-18 07:58 CET
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 5.28 seconds
I did a wireshark capture before, but reading that was to complicated for me ;-)
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
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

If your pi is connected to your tv, you can uses cec to put in on...
User avatar
Mediacj
Posts: 74
Joined: Wednesday 11 February 2015 16:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Samsung Smart TV (on or off)

Post by Mediacj »

Thx trixwood for your great iSamsungTV!

I have a F serie Samsung from 2013 and I managed to send keys to the tv volume up down switch channel etc.
The only thing I can't get to work is the SMS function, would love to send status messages from Domoticz to my TV.

When I send this command: iSamsungTV F 192.168.1.68 -SMS "" "" "" "" "" "" "Get Off The Couch" I get this error:

Code: Select all

*** buffer overflow detected ***: iSamsungTV terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fbdeab477e5]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7fbdeabe856c]
/lib/x86_64-linux-gnu/libc.so.6(+0x116570)[0x7fbdeabe6570]
/lib/x86_64-linux-gnu/libc.so.6(+0x116a13)[0x7fbdeabe6a13]
iSamsungTV[0x40125b]
iSamsungTV[0x4012ef]
iSamsungTV[0x4022d6]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fbdeaaf0830]
iSamsungTV[0x400a29]
======= Memory map: ========
00400000-00405000 r-xp 00000000 fc:00 926472                             /usr/local/bin/iSamsungTV
00604000-00605000 r--p 00004000 fc:00 926472                             /usr/local/bin/iSamsungTV
00605000-00606000 rw-p 00005000 fc:00 926472                             /usr/local/bin/iSamsungTV
010b4000-010d5000 rw-p 00000000 00:00 0                                  [heap]
7fbdea8ba000-7fbdea8d0000 r-xp 00000000 fc:00 524823                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fbdea8d0000-7fbdeaacf000 ---p 00016000 fc:00 524823                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fbdeaacf000-7fbdeaad0000 rw-p 00015000 fc:00 524823                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fbdeaad0000-7fbdeac8f000 r-xp 00000000 fc:00 541085                     /lib/x86_64-linux-gnu/libc-2.23.so
7fbdeac8f000-7fbdeae8f000 ---p 001bf000 fc:00 541085                     /lib/x86_64-linux-gnu/libc-2.23.so
7fbdeae8f000-7fbdeae93000 r--p 001bf000 fc:00 541085                     /lib/x86_64-linux-gnu/libc-2.23.so
7fbdeae93000-7fbdeae95000 rw-p 001c3000 fc:00 541085                     /lib/x86_64-linux-gnu/libc-2.23.so
7fbdeae95000-7fbdeae99000 rw-p 00000000 00:00 0 
7fbdeae99000-7fbdeaebf000 r-xp 00000000 fc:00 541081                     /lib/x86_64-linux-gnu/ld-2.23.so
7fbdeb0b2000-7fbdeb0b5000 rw-p 00000000 00:00 0 
7fbdeb0bb000-7fbdeb0be000 rw-p 00000000 00:00 0 
7fbdeb0be000-7fbdeb0bf000 r--p 00025000 fc:00 541081                     /lib/x86_64-linux-gnu/ld-2.23.so
7fbdeb0bf000-7fbdeb0c0000 rw-p 00026000 fc:00 541081                     /lib/x86_64-linux-gnu/ld-2.23.so
7fbdeb0c0000-7fbdeb0c1000 rw-p 00000000 00:00 0 
7ffec08b3000-7ffec08d4000 rw-p 00000000 00:00 0                          [stack]
7ffec0905000-7ffec0907000 r--p 00000000 00:00 0                          [vvar]
7ffec0907000-7ffec0909000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)
My system is a Ubuntu server 16.04.1 LTS

When I use the popup script which I changed because I couldn't give the series with the parameters so I added a extra parameter:

Code: Select all

#!/bin/bash
iSamsungTV $1 $2 -SMS "" "" "" "" "" "" $3
sleep 0.3
iSamsungTV $1 $2 -KEY KEY_ENTER
sleep 3
iSamsungTV $1 $2 -KEY KEY_ENTER
Then I gave this command: iSamsungTVPopup.sh F 192.168.1.68 "this is a test"
I get the help text from iSamsungTV so that seems a syntax problem. Also with the unchanged version of iSamsungTVPopup.sh with and without the series letter.

Has anyone with a F series Samsung TV managed to get a SMS on the screen?
trixwood

Re: Samsung Smart TV (on or off)

Post by trixwood »

Ha it crashes. I will create a debug version with debug print statements and bigger buffers... see where it crashes... :-)
evertide
Posts: 14
Joined: Wednesday 19 November 2014 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Contact:

Re: Samsung Smart TV (on or off)

Post by evertide »

Hi Thanks...

I have a E TV and could not get the SMS to work either.

The help text also mentioned getting a status messges on which source (hdmi) is used. Could you point me how to do that.

Regards
Sanderr2
Posts: 2
Joined: Saturday 10 December 2016 0:08
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by Sanderr2 »

Hello,

I have been reading this topic and first off i have to say I am a complete noob when it comes to programming etc.
I have a samsung tv and I have domoticz installed on my synology nas. I have managed to use the events to create a scene in which all lights dim or light up. Now I would like to make the connection to my samsung tv. So if I turn on the tv I would like to have my lights turn on as well. Second and most important to me. When I play a movie with the ds synology app installed on my samsung tv i would like the lights to dim.

Is this in anyway possible? I know it is with the kodi media player but I am hoping it works with the synology apps as well.
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 »

You can use the 'system alive checker ', this will ping the TV. The TV will only reply when it is turned on.
I'm not sure how to do the synology part
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Sanderr2
Posts: 2
Joined: Saturday 10 December 2016 0:08
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Samsung Smart TV (on or off)

Post by Sanderr2 »

Thanks! I figured that out as well. I read about it yesterday but I couldn't enter my TV IP address. But when you create the hardware it indeed is possible to change the setup and enter the IP there afterwards. Domoticz can now register TV on or off. So part 1 is finished :D ..

Off course I can do the same for the synology itself. Say it registers synology on and tv on dim lights but I think since domoticz is now working from the NAS it wont go in standby anymore when nothing is done with it. This is an issue anyway because I really want the synology to go in standby. Does anybody know whether or not it is possible with domoticz that the synology still turns to standby mode?

So I am still not sure how to make the lights dim when I play a video with the synology ds video app on my samsung tv. After reading some forums is it possible to dim the lights when pressing a specific button on the tv remote? Maybe Domoticz can recognize the play and pause button of my remote since I only use those for films etc. Or something else I was thinking of, is it possible to figure out the ip with specific port from which the ds video player of the nas sends it signal to the ds video app of the tv? If i can ping this signal the same way it might also work. Any help is welcome thanks :D
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests