Indigo and Global Cache GC-100 control

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Tue Sep 27, 2011 9:32 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Indigo and Global Cache GC-100 control

dnomode wrote:
I'm bummin. I don't have a clue about Python. Can we just send HTML to The GC-100 device? Are you controlling your TV with RS232 using Indigo? How you doing it?

I'll start a new thread on that in a couple of days. I'm a bit busy right now.
Before I got my GC-100 module, I didn't have a clue about Python either.
But it's easy to learn and there are plenty of examples on the internet.

Here's a very small example that might work for you:

Code: Select all
# Echo GC100 Example
import socket

indigo.server.log("Send string to TV")

HOST = "<ip address GC-100>"  # The remote host
PORT = "4999"  # The same port as used by the server

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, int(PORT)))

s.send('\xDF\x80p\xF8\x02\x00\x006' + chr(13))
data = s.recv(512)

dataVariable = indigo.variables["TVData"]
dataVariable.value = data
dataVariable.replaceOnServer()

s.close()

Copy this code into an Action Group for embedded Python code.
Replace <ip address GC-100> with the actual IP address from your module.
You will also have to create an Indigo variable named "TVData".
If there is a response from the TV, it will be stored there.

You might have to tweek the code a bit to get it working.

If you want pictures from my TV as an Indigo client: click!

Posted on
Tue Sep 27, 2011 11:06 pm
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: iRed2 users, UNITE!

:D :D :D :D :D :D :D :D

Macpro you are the man

I just tried your code and it worked. It does not work consistently however that's something a little tweaking should fix. For some reason I need to send the command two time to the TV for it to work.

I'll play with it some more in a few days.

Thank you very much.

Ed

Posted on
Wed Sep 28, 2011 10:23 pm
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: iRed2 users, UNITE!

Hey Macpro,

Is it possible to do this with Applescript. The Python script seems to run slower then Applescripts that I've used in Indigo (slower then what I'm used to, and I'm no pro so I could just be trippin). Every time I execute the command in Indigo it seems to run forever in the bottom left corner of Indigo (ok not forever, however longer then I like) and then I get this message:
Code: Select all
Stopping plugin "embedded script executor host". This may take a few seconds.

If yes, whats the benefit of running Applescript over Python and vice versa?

Note: I know that I'm no longer talking about iRed. I feel as if I should ask the question here since it started here. :oops: I hope it's okay.

Thank You
Ed
Last edited by dnomode on Wed Sep 28, 2011 11:27 pm, edited 1 time in total.

Posted on
Wed Sep 28, 2011 10:36 pm
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: iRed2 users, UNITE!

@Matt and Jay: could you please put the RS232 conversation in a new thread called "Indigo and Global Cache GC-100 control"?

@dnomode: I thinks it's possible, because there are libraries available to let AppleScript talk to sockets. But I managed to get Python running first, so didn't try AppleScript anymore.

To speed things up, try the following: put the contents of your Python code in a script and save it /Library/Application Support/Perceptive Automation/Indigo 5/Scripts/External Scripts.

Then change your Action Group to run the code from this script.

It's the way I'm running my code.

Posted on
Thu Sep 29, 2011 8:21 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: iRed2 users, UNITE!

dnomode wrote:
Hey Macpro,

Is it possible to do this with Applescript. The Python script seems to run slower then Applescripts that I've used in Indigo (slower then what I'm used to, and I'm no pro so I could just be trippin). Every time I execute the command in Indigo it seems to run forever in the bottom left corner of Indigo (ok not forever, however longer then I like) and then I get this message:
Code: Select all
Stopping plugin "embedded script executor host". This may take a few seconds.

If yes, whats the benefit of running Applescript over Python and vice versa?

Note: I know that I'm no longer talking about iRed. I feel as if I should ask the question here since it started here. :oops: I hope it's okay


The stopping plugin display box, should rarely show... It's an indication that the plugin is not shutting down cleanly, and could be busy processing something.

So that could indicate that the plugin is busy, or has a bug...

But to answer the first question, why Python over applescript?

Now, please keep in mind, most of my plugins where in Applescript. I am in the process of converting, or have converted, the majority of my plugins to Python...

Applescript, is a annoying language to work in. Yes, it's a human readable, but that's a double edged sword, it makes it easy to read, but small details are remembered incorrectly about the syntax, and that human readable code makes it harder to debug....

Python is easily extendible, quite powerful, and quite fast...

Here's a good example... (http://www.timestretch.com/article/mand ... _benchmark )

The timings below are from a Mandelbrot Fractal benchmark.

Time in seconds Relative Time
C gcc-4.0.1 0.05 1.00 x
Python 2.5.1 9.99 199.80 x
Applescript 71.75 1435.00 x

Python v2.51, run the entire suite in just under 10 seconds, pretty fast... But considering that a pure C implementation did it in under 1 second, it could use some improvements...

Keep in mind, Python v2.71, run it in less than 2 seconds... (And that's without using any optimized math accelerators...)

The Applescript implementation took 71 seconds, according this benchmark...

Now, keeping in mind, this benchmark is old... I also re-ran the Applescript benchmark under Lion, and it took 9 seconds... But still, that's quite a bit of difference between the Applescript & Python coding...

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Thu Sep 29, 2011 9:28 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: iRed2 users, UNITE!

macpro wrote:
@Matt and Jay: could you please put the RS232 conversation in a new thread called "Indigo and Global Cache GC-100 control


I'm afraid that this thread has become a bit too intermingled to easily separate out specific parts. I suggest starting a new thread - summarize what's been said so far and the continue the conversation there. You can put a pointer to that thread here.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Sep 29, 2011 1:30 pm
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: iRed2 users, UNITE!

Hey Jay,

Can you just start a thread with the last few post starting with Macpro's post on Tue Sep 27, 2011 9:32 am

Thanks
Ed

Posted on
Thu Sep 29, 2011 1:58 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo and Global Cache GC-100 control

Done.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Sep 30, 2011 3:53 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Indigo and Global Cache GC-100 control

My previous TV was controlled by Indigo using iRed and IRtrans modules. But my new TV has an RS232 interface and my dealer gave me the specifications to control the TV.

First challenge was to connect the RS232 interface from the TV in the living room to the Indigo mini in another room.
Because iRed has support for the Global Caché modules, I bought a GC-100 module.

But iRed support for RS232 is still limited and can only send data to the TV. Getting a response back or getting TV initiated data into the Mac is not possible right now. The iTest program from Martijn Rijnbeek is capable of doing all the things I need, but unfortunately is not scriptable, so I can't integrate that with Indigo.

That's when I decided it was time to start learning Python and write my own interface. With the help from Jay and Perry The Cynic I managed to get Indigo connected to my TV.

Communicating with the GC-100 module is easy. See this example script I wrote for dnomode:
Code: Select all
# Echo GC100 Example
import socket

indigo.server.log("Send string to TV")

HOST = "<ip address GC-100>"  # The remote host
PORT = "4999"  # The same port as used by the server

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, int(PORT)))

s.send('\xDF\x80p\xF8\x02\x00\x006' + chr(13))
data = s.recv(512)

dataVariable = indigo.variables["TVData"]
dataVariable.value = data
dataVariable.replaceOnServer()

s.close()


Of course my script is a bit bigger than that because it has a lot more functionality. More on that later.

So what can I do with my new TV?
- Control lights and appliances in the house using the TV's remote control
- Control the SqueezeBox music player using the TV's remote control
- See the outside temperature

What can I do with my Mac?
- Switch on the SqueezeBox and TV to listen to music
- Control the settings of the TV like channel and volume
- See what TV channel is being watched on TV

What can I do with my iPhone/iPad?
- Switch on the SqueezeBox and TV to listen to music

(The SqueezeBox is connected to the TV to play music. I no longer have a separate amplifier for that.)

But enough words. It's picture time!

Image

This menu is created by the Mac mini and sent to the TV using the RS232 module.
Using the green key on the TV remote I can switch on the "Vloerlamp".
The TV will send this command to the Mac mini and then Indigo will do it's magic to switch the light on.
Next the status on the TV screen is updated so I can see that the light is on.
(Or I can take a look at the light :wink: )
The red key will switch the light off and again the status is updated on the TV screen.

Here's another example where it shows lights and appliances in the garden. But it also shows the outside temperature.

Image

The entire menu structure that I use on the TV is stored into Indigo variables.
Some variables define menu lines, other variables define switchable devices, dimmable lights and even variable values.
This means that I can change the way the menu looks without changing a line of code.

The downside is that it the menu variables are not easy to read.
Here are some examples from the menu on the picture above:

TVM064000 = S;Vijververlichting;Pond
TVM065000 = V;Buitentemperatuur;AWTemperature;°

The variable names TVM064000 and TVM065000 contain information on their position in the entire menu hierarchy. The first position in the value tells what kind of menu line data is stored. "S" stands for a switchable device and it has a display name and an Indigo device name.
The "V" stands for a variable and this one also has a display name, Indigo variable name and an optional suffix for the variable value. In this case the centigrades symbol.


The latest changes I made are sending messages to the TV.
When there is someone at the front door, a messages pops up.

And for those of you who remember my dryer topic: not only does my wife get an e-mail when the dryer is ready, but now also a message shows up on the TV.

This is another approach on integrating Indigo and other components. The biggest advantage for us is that we now can use the TV remote to control lights and devices in our house. We don't use iOS devices for that.

Posted on
Fri Sep 30, 2011 7:19 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Indigo and Global Cache GC-100 control

Cool -- thanks for sharing your setup!

Image

Posted on
Sat Oct 08, 2011 9:14 am
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: Indigo and Global Cache GC-100 control

Hey Macpro,

That is pretty awesome. I was happy with just turning my tv ON and OFF. I had no idea we could do stuff like that. Are you willing to share your scripts so I can learn a little more about this?

Thanks
Ed

Posted on
Sat Oct 08, 2011 9:32 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

Re: Indigo and Global Cache GC-100 control

Does your TV support this kind of control? Loewe TVs have special commands to compose menus and display them on screen.

Posted on
Thu Oct 20, 2011 2:14 pm
dnomode offline
Posts: 366
Joined: Apr 12, 2008
Location: North Georgia

Re: Indigo and Global Cache GC-100 control

No, It doesn't :(

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests