Telnet Question

Hey guys

I Know I’m being an n00b here and missing something very easy.

I’m looking to build a remote control using Openremote to control some Z Wave devices and to control my TV’s running MediaPortal. So far I’ve got the Z Wave devices running fine but having a few issues controlling MediaPortal.

MediaPortal has a plugin call WiFi remote, you can download an app on Android and use it that way or you can send telnet commands to it

I can telnet to the device and issue commands and it controls MediaPortal fine, once I try it from Openremote I run into problems

I’ll run through the process I’ve completed

First from telnet
C:\telnet 192.168.. 8017
{‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}

First command just logs you in and lets you issue commands

{‘Type’:‘key’, ‘Key’:‘m’}

Key m is just the mute button, once issued the TV is mute\muted

All that works fine

I then added the commands to OpenRemote, so I created two new commands

Name: Connect
Protocol: Telnet
IP:192.168..
Port:8017
Command: null|{‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}

Name: Mute
Protocol: Telnet
IP:192.168..
Port:8017
Command: null|{‘Type’:‘key’, ‘Key’:‘m’}

I then mapped them to buttons on the GUI, so I press the connect button first to login and then mute button but that’s it nothing happens in MediaPortal. I check the logs and I see the command have been sent successfully

DEBUG 2016-11-01 17:04:02,167 (Telnet): Building Telnet command
DEBUG 2016-11-01 17:04:02,167 (Telnet): Telnet Command: port= 8017
DEBUG 2016-11-01 17:04:02,167 (Telnet): Telnet Command: command = null|{‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}
DEBUG 2016-11-01 17:04:02,167 (Telnet): Telnet Command: ipAddress = 192.168..
DEBUG 2016-11-01 17:04:02,167 (Telnet): Telnet Command created successfully
INFO 2016-11-01 17:04:02,198 (Telnet): send: {‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}
DEBUG 2016-11-01 17:04:31,823 (Telnet): Building Telnet command
DEBUG 2016-11-01 17:04:31,823 (Telnet): Telnet Command: port= 8017
DEBUG 2016-11-01 17:04:31,823 (Telnet): Telnet Command: command = null|{‘Type’:‘key’, ‘Key’:‘m’}
DEBUG 2016-11-01 17:04:31,823 (Telnet): Telnet Command: ipAddress = 192.168..
DEBUG 2016-11-01 17:04:31,823 (Telnet): Telnet Command created successfully
INFO 2016-11-01 17:04:31,823 (Telnet): send: {‘Type’:‘key’, ‘Key’:‘m’}

I do have a work around in place at the moment, using my Z Wave controller (Vera Lite) I created a scene and can send LUUP code and it will then issue the correct command

LUUP Code:

local Inlog="{“Type”:“identify”,“Name”:“Vera”,“Application”:“VeraGos”,“Version”:“0.0.1.1”,“Authenticate”:{“AuthMethod”:“none”}}"
local wmcCmd = “{“Type”:“key”, “Key”:“m”}”
local socket = require(“socket”)
tcp = assert(socket.connect(“192.168..”, 8017))
tcp:send(Inlog … “\r\n”)
luup.sleep(100)
tcp:send(wmcCmd … “\r\n”)
tcp:close()
return 0

I would like it if Openremote could send the command straight to MediaPortal and not have to jump off my Z Wave box

Thanks

It sounds like your box may be session based?
i.e. it expects you to create a session, login, maintain the session, send commands, log off?

OpenRemote telnet will connect, send a command, and disconnect. Your login is quite probably working, but the next command is a new command/session and not logged in…

Try it as a single command…

null>{‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}|null|{‘Type’:‘key’, ‘Key’:‘m’}

That’s “waitfor nothing”, “send command”, “wait for nothing”, “send command”.

If the 1st command responds with a string, you can insert that string in the 2nd “null”, to telnet waits for it before sending.

Also, a swift Google shows that whilst you can set AuthMethod to “none” (as you have), this page:

http://wiki.team-mediaportal.com/1_MEDIAPORTAL_1/17_Extensions/3_Plugins/WifiRemote/Messages#Authentication_Response

Says:

Autologin is a feature designed for clients that can’t keep the connection open all the time. It has to be enabled in WifiRemote configuration. When it is enabled an autologin key will be sent on successful authentication. Every command containing this key (as parameter “AutologinKey”) will be accepted for x minutes (defined in configuration), even if the client disconnected and reconnected inbetween without sending an identify message.

It may be you need to look into that a bit more? (or set userpass and send that each time)

Hi Peter

Thanks for the replay

I gave that ago and combined the two strings

DEBUG 2016-11-03 17:15:04,835 (Telnet): Building Telnet command
DEBUG 2016-11-03 17:15:04,835 (Telnet): Telnet Command: port= 8017
DEBUG 2016-11-03 17:15:04,835 (Telnet): Telnet Command: command = null|{‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}|null|{‘Type’:‘key’, ‘Key’:‘m’}
DEBUG 2016-11-03 17:15:04,835 (Telnet): Telnet Command: ipAddress = 192.168.9.17
DEBUG 2016-11-03 17:15:04,835 (Telnet): Telnet Command created successfully
INFO 2016-11-03 17:15:04,835 (Telnet): send: {‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}
INFO 2016-11-03 17:15:04,835 (Telnet): send: {‘Type’:‘key’, ‘Key’:‘m’}

Says it sent in the logs but still not coming though via MediaPortal

If I ever get it working then I may look into the autologin option

If you look at the LUUP code for Z Wave

tcp = assert(socket.connect(“192.168..”, 8017))
tcp:send(Inlog … “\r\n”)
luup.sleep(100)
tcp:send(wmcCmd … “\r\n”)
tcp:close()
return 0

lupp.sleep(100)

so that’s waiting before sending the next command, can I do that in OpenRemote?

Thanks

May I make a random suggestion without knowing anything about either of these systems?

Could you push the various command strings into an in memory register, then have a rule that looked for changes in that register and push that value into a catch all telnet command?

That way a log in command can be sent in the rule, a wait, followed by your required command.

Does that help at all?

AFAIK, the only way to “wait” is use a macro, but that will still send two commands.

I think you need to look into the session authenticate/autologin thing a bit more.

Hey Peter

I had some free time at the weekend and played abit more with the coding and managed to get it working

I changed the second null to 1 and it worked

null>{‘Type’:‘identify’,‘Name’:‘My PC’, ‘Application’:‘CouchPotato’, ‘Version’:‘0.3.1.2’, ‘Authenticate’:{ ‘AuthMethod’:‘none’}}|1|{‘Type’:‘key’, ‘Key’:’{m}’}

Many thanks for pointing me in the right direction

Cheers

No worries - glad you got it working :slight_smile:
It’s a shame my Onkyo doesn’t speak telnet (special characters for the fail) - so I need to sort out my TCP issue…(see other post)