United Kingdom
Asked — Edited

Telnet And Eventghost (Or Python)

It's been requested so here it is... a quick (and brief) look at TELNET.

First off, you can view DJ's video on TELNET for some info on how it works, here it is...

Which is great and covers the TELNET application but if you want to use something else, say EventGhost you'll need to know how.

The first steps are the same, enable the server for the board(s) you want to control, DJ covered this in the video so I wont repeat it.

Now, in EventGhost you will need to add a Python Script. This is a very basic Python script I have knocked up to show it working. You may need to change IP addresses and ports to suit your ARC but that should be easy enough to see how.

In EventGhost I have a Python Script written;

from socket import *
import time
HOST = '192.168.0.100'
PORT = 6666
ADDR = (HOST,PORT)
BUFSIZE = 4096
cli = socket( AF_INET,SOCK_STREAM)
cli.connect ((ADDR))
data = cli.recv(BUFSIZE)
cli.send('$incoming = "Hello, I am Event Ghost"')
cli.send('\n')
cli.close

HOST and PORT may need changing for you. This script simply sets a variable $incoming to be "Hello, I am Event Ghost". Run it and the command is sent to ARC, the variable is set.

I have added a simple EZ-Script to ARC, something that will use the variable that was set.

# Set up the variable so that it exists
$incoming = 0

# Set up a loop
:loop

# Wait until data received from EventGhost
WaitForChange($incoming)

# Speak the incoming text
SayWait($incoming)

# Loop back to the start
Goto(loop)

Now, the Python script will set the variable $incoming to the specified phrase, the script will see the change and will speak the phrase.

Also added is the Variable Watcher, which should show a change in the variable.

Also the debug window is added so you can see the connection happen.

Hopefully (it's currently uploading) here is a video of the example code above working and ARC being controlled by EventGhost... NOTE: TURN DOWN YOUR VOLUME! The sound went a bit wrong, I guess I forgot to set the audio device and it used the mic not the speakers so sound is messed up and very loud.

I also showed some other script commands, however the servo one didn't work but that was due to not being connected to an EZ-B at the time of testing. I'm too lazy to cut it out of the video.

Hopefully that should give an indication in to how to get EventGhost (or anything that uses Python) to talk to ARC. Writing the Python scripts is a more in depth process and there is a multitude of resources on the internet which should be able to help you work out how to write the code which sends other variables in to ARC (I am unable to show my code which creates the cli.send at this time due to a whole bunch of things that are going on with Jarvis right now - sorry it's vague, I wish I could say more).


ARC Pro

Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

#1  

How about EZ-B talking back to an app (like Eventghost?). I see script commands for http gets, file IO, twitter posting, and executing apps form the command line, but I don't see anything for simple tcp communication (telnet). Am I missing it, or is this currently a one way interface?

Although any of the above could be used for integration to external apps, I agree with you that telnet is incredibly simple text based protocol with no particular required nomenclature, which gives a lot of freedom when creating external interfaces (and most important for me, I already have experience writing apps with it in VB, so the transition to .NET when I finally get around to it should be easy).

There was some recent discussion about a plugin framework for EZ-B to interface with 3rd party SDK's, and I understand DJ's reluctance on that front since it is impossible to guarantee code quality, but really, as long as we have simple communication methods to external apps, and those apps have SDK's or already support those interfaces, there is no particular reason a plugin needs to exist within EZ-B. Just write a script to send commands to the external app.

Alan

United Kingdom
#2  

This example was only one way communication, to send information to ARC from other apps, trigger scripts, move servos etc. mainly to show @irobot as he requested in a different thread which I didn't feel should be hijacked with this, it is not intended as a tutorial (hence no tutorial flag on the post). Currently I only use one way communication with ARC and I have no intention on requiring two way communication however when I have more time on my hands I'll look in to two way communication over telnet.

Ideally it will spur others to discuss their telnet methods etc. though.

#3  

Awesome @Rich! above and beyond the call of "request" thank you so much ! Your explanation is "rich" with detail and substance, while you might not call it a tutorial I certainly do! I now have lots to study this evening and imagine/create how I will use it! I have last night (til midnite, and I know Rich and DJ put in those hours ALL the time) completed a number of EG "action s " to begin listening to music from online and from my own collection. Now I want to have ARC talk to EG I have seen DJ's tutorial before but didn't fully realize its "scope" Soooo with a demo bot set up in DJ's workplace someone from the UK or south Carolina or Salt Spring Island can control it! I think that would be awesome media/fun/social event sometime to set up ....@DJ ....what do you think of that idea? Perhaps when the EZ V4 has arrived! :)

United Kingdom
#4  

Midnight is early for me lol (I am posting this at 1:55am! Edit: it was 2:06am when I finished writing it)

The above example would control ARC from EventGhost rather than send EventGhost data from ARC, I don't have anything where ARC talks to EventGhost but I will look in to it when I get the chance, I don't expect it's too difficult.

Some examples of what I use (or plan to use more to the point, since Melvin isn't finished and has once again been put to one side) EventGhost and ARC for are; To tell the robot what music is being played, rather than relying on listening with microphones he is told over telnet. This enables cool little gimmicks like him suddenly shouting out "Oh I love this song" or starting to dance. To tell the robot what film is on, including the exact part of the film. This enables more gimmicks like him laughing if he is watching it, hiding, screaming, reciting the words to his favourite parts. To tell the robot the current room temperatures. To tell the robot the current load on the power. To tell the robot which appliances are on and off along with any changes of status - for instance if the washing machine finishes a wash the robot could switch to face tracking, find a face and then say "the washing has finished". To tell the robot if any new TV shows, films or music have been added to the library. To tell the robot if there is a power failure (after detection by the UPS) so it can safely shut down before the PC running ARC shuts down.

Mainly, it's gimmicks and little scripts to make the robot seem more lifelike but I am sure there are a whole lot of other functions that could be thought up, especially since EventGhost can control and monitor anything on the PC.

Also, with even the V3 the robot could be easily controlled from anywhere in the world. That's the beauty of the HTTP Server control:) But better still, with Telnet/server enabled in the connection options you can connect a copy of ARC from one PC to another copy of ARC running on a different PC halfway around the world. I have tested it from work to home before and it worked very well (you just need to port forward the correct ports (defaults to 6666) to the correct internal IP address)

#5  

Perfect! Great explanation...That's exactly the kind of activity/behavior I want from a robot! Jarvis is amazing but I am inclined towards something interactive and mobile..In your last paragraph you described something I have suggested to DJ as a media/promotion/fun day were Forum members could control a demobot based in Calgary from any of the Forum members ...like from the UK ,France, Netherlands ,West Coast of British Columbia(:) )...we'll see what he says.. I think your idea of EZ-Robot paired with something like EG and Telnet will greatly add to "Revolution" ...IMO:)

New Zealand
#6  

Hey Rich,

You mentioned the possibility of sharing your thinking about the two way communication with ARC....

"I don't have anything where ARC talks to EventGhost but I will look in to it when I get the chance, I don't expect it's too difficult."

I've got ARC responding to Eventghost but what about the other way round?

What would be your IMO on the subject?

@Tameion

United Kingdom
#7  

The other way around, I have something somewhere... I've not touched on it for a while and all I have saved in EventGhost is the following very rough and quick python example...

from socket import *
import time
HOST = '192.168.0.100'
PORT = 6666
ADDR = (HOST,PORT)
BUFSIZE = 4096
cli = socket( AF_INET,SOCK_STREAM)
cli.connect ((ADDR))
data = cli.recv(BUFSIZE)
cli.send('$incoming =')
cli.send('"Hello ARC"')
cli.send('\n')
cli.close

This basically creates the variable (or updates the variable) $incoming to be set to "Hello ARC"

United Kingdom
#8  

Sorry, I read too quick, you want EG to respond to something ARC sends?

I did do this too, I'll see what I can find.

#9  

This is really cool. I am blown away by ARC more each day. Thanks Rich for posting this and Thanks DJ and team for adding such cool features to the platform.

United Kingdom
#10  

I remember why I can't find what I'm looking for in EventGhost and that's because I did ARC to EventGhost via HTTPGet() and a web page running on my home server which communicates with Event Ghost.

I think I have posted the PHP code before but I'll post it again later (tomorrow) when I get the chance.

New Zealand
#11  

Yes I've read that Rich.... I would have done something similar but I'm hoping for a different method.... perhaps something along th lines of a command like

exec telnet "variable=:=success"

I am sold on EZ-Robot but I want to pass off some of the mundane things to EG to manage. I need to have ARC intelligently feed back to Eventghost a change of status confirmation that it has completed an action.

Hence the need for two way communication....

New Zealand
#12  

Looking around the web and at a few of your earlier posts in the Artificial Intelligence thread I got to thinking about the exec command in ARC. ... and wondered if we could trigger an event in Evenghost from the command line.

I found a post on an Android phone forum for two Apps called Autoremote and Tasker. Their "tips and tricks" page gave an example of a phone triggering an action in EventGhost.

Eg. "C:\Program Files (x86)\EventGhost\EventGhost.exe" -event CoolEvent payload

So I got to fiddling around and .... Exec("Eventghost", "-event Media_Player_On" ) or Exec("Eventghost", "-event Media_Player_Off" ) works a treat!

Eventghost receives the request and looks for the event trigger... assuming you have placed that trigger in a macro you have created earlier you can execute anything you like!

Now...... You posted in the Artificial Intelligence thread that you had been doing some

Quote:

...integration via Telnet so that ARC (and it's scripts) are aware of everything they need to be aware of (i.e. if media playback starts, EventGhost sends ARC a script command $mediaplayback = 1, when it's finished it sends $mediaplayback = 0 (that's a very simple example, it also sends more info on the media).

Can you enlighten me how you passed the variables you store in EG via telnet to EZB?

Just the line syntax will do. Does it behave as if it were a direct console variable entry? Eg. $Apples=1
or do I have to do something extra?

How does EZB convert the Telnet line into a variable without some elaborate sequence of inputs being manually connected.... ie Send#54=$Apples, Send#55=pears ?

@Tameion

United Kingdom
#13  

I don't currently pass variables from EG to ARC, I set variables in ARC using EG.

My python script example shows how this is done, simply updating a variable with the script command $incoming = "Hello World"

I have had EG send it's variables data to ARC (i.e. current electrical load on th emains incoming electrics, room temperatures etc.) previously however I have since upgraded the PC and didn't carry those python scripts over as I prefer to use ARC to fetch that data directly from the MySQL server (which EG writes to).

I'll have to find my old notes on it which is more than just difficult with the way I file things... When I find them I will look but to be honest I wouldn't hold your breath, I have a million and one other things to do at the moment unfortunately.

New Zealand
#14  

@Rich

I won't Rich.... and please stop looking!

And thanks for your faithful support of the community.

I suspect our journeys have been very similar but you're a step or two ahead of me and if you've moved away from passing variables via telnet then using a SQL database to store and manage the variables is obviously the way to go....

I had planned for that ultimate eventuatility ...

I take it that you grab your data from media XBMC's database as well?

  • Wayne
United Kingdom
#15  

Yep, and XBMC is set up for MySQL too (I have a multi seat install so one database works best for me - upnp probably would work better but it was originally set up before upnp was introduced). I have heard that MySQL support is to be dropped from XBMC/KODI at some point though.

Everything in one easy to use database, simple PHP pages to pull the specific data when needed and HTTPGET() for ARC to get those details. i.e. HTTPGet("http://192.168.0.107/Jarvis/humidity.php";) will get the current humidity. HTTPGet("http://192.168.0.107/Jarvis/currentpower.php";) will get the current load on the power to the house.

All very simple PHP pages, based off of a simple template but the SQL query changes for each and then it just return the value in plain text on the page, no frills, no extra formatting, just the value so the variable is nice and easy to use.

I also have a more complex PHP page set up which displays everything with fancy graphics etc. but ARC doesn't like the returned results that much.

#17  

Hello Rich, The DJ video shows a checkbox for "Script Interface" that is not available in the current version of EZB 2016.10.19.00

The on screen instructions indicate that there is still an option, but I can't find it.

Please see included screen snips

Thanks, Frank

User-inserted image

User-inserted image

PRO
Synthiam
#18  

It's right there above the paragraph in your screenshot. You're looking right at it:)

The paragraph that you highlighted is within the boundaries of the TCP EZ-Script Shell Server Settings section. Just like your sock drawer, computer menus and displays put things into categories.

#19  

Hello DJ, I guess I was expecting a separate checkbox...:) my socks aren't organized....

I can now Telnet into it with that box checked and EZB commands work fine, just not the help command.

Since there is only one checkbox, does that mean that EZB to EZB communication is not supported? When I try that I get the message that its not an EZB. If I uncheck the box, it can't connect at all

Regards, Frank

User-inserted image