TSU9600 Tips & Tricks

Forum about hardware/software for the Philips Pronto TSU9600 and other remotes.

TSU9600 Tips & Tricks

Postby Digit » Sat Dec 29, 2007 11:24 pm

Today was Pronto-day. Learned a lot, and some of those things can be useful, so i thought let's make a topic of this.

First of all, i just *had* to get rid of those scripts full of indexOf(), substrings etc. just to parse data coming from my HA app.
So i thought i'd give XML a try. This is so easy...

First i configured my HA app, which has a built-in HTTP-server, to supply the Pronto with XML. Prontoscript does the rest...
Here's a sample of XML i use (without the HTTP headers):
Code: Select all
<body>
  <content>
    <item>
      <ID>K01</ID>
      <Value>0</Value>
    </item>
    <item>
      <ID>K02</ID>
      <Value>0</Value>
    </item>
    <item>
      <ID>K03</ID>
      <Value>0</Value>
    </item>
    <item>
      <ID>K04</ID>
      <Value>0</Value>
    </item>
  </content>
</body>
Now, before you can parse the response (=HTTP headers + XML) in the Pronto you have to do this:
Code: Select all
// get rid of HTTP headers.
result = result.substring(result.indexOf("<body>"));
// create an XML object.
var xx = new XML(result);
With these 2 lines, you can directly address the data you need:
xx.content.item[0].ID.text() will result in 'K01'
xx.content.item[2].ID.text() will result in 'K03'
xx.content.item[0].Value.text() will result in '0'

In my case, i use this to retrieve the status of the lights in the livingroom. Depending on their status, different icons are shown on the Pronto.
It goes something like this:
Code: Select all
// get the ID.
var s = xx.content.item[i].ID.text();

// get the button.
var w = widget(s.toString());

// determine the status: ON or OFF.
status = xx.content.item[i].Value.indexOf("1") < 0 ?"OFF":"ON";

// set the button label
w.label = status;

// get the right image depending on the status.
var v = CF.widget("LED_"+status, "RESOURCES");

// if found, transfer image to the button.
if(v)
{
  w.setImage( v.getImage() );
}
So, with only a very small amount of code i can have the pages on my Pronto display whatever can be retrieved from my HA app: light status, temperatures, you name it... ain't that nice?[8D][8D]
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Snelvuur » Sat Dec 29, 2007 11:29 pm

Someone has been busy ;) i do agree, if you know enough you can make anything you want. Barry on remotecentral pointed me to a book, but it does not sell in netherlands afaik. Still.. i need to do some exams for something else first (work related) which is pretty dull. I should put these examples on the wiki perhaps. To learn as examples, since i think there are not enough. Is that an idea?

// Erik (binkey.nl)
User avatar
Snelvuur
Forum Moderator
Forum Moderator
 
Posts: 3155
Joined: April 2007
Location: Netherlands

TSU9600 Tips & Tricks

Postby Digit » Sat Dec 29, 2007 11:39 pm

Erik,

Good idea, that will make life a bit easier, forum search is not that handy...

Robert.

PS.
What book are you referring to? About Javascript? Flanagan? I mostly use http://developer.mozilla.org/en/docs/Co ... _1.5_Guide for that.
Saves you the money for a book...and till now, this guide was helpful enough.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Bwired » Sun Dec 30, 2007 12:14 am

Hi Robert,
Looks very nice, couple of questions.
What if the pronto is not on? or is it always in standbye and can therefor receive your xml's
If it was not ON then you have to pull the current status?
How is it handled by the Pronto, fast without noticing, has the status screen to be on top or is it still being upgraded even when your doing other things with the pronto.

You can see that I Still did not receive my Pronto, hopefully Monday
Thanks.Pieter

BTW created a new forum for the Pronto TSU9600
User avatar
Bwired
Administrator
Administrator
 
Posts: 5308
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Digit » Sun Dec 30, 2007 12:33 am

The Pronto is always on, but you can set a wireless timeout ranging from 15 min. to 24 hours. But it's not a question of receiving xml's, it's about requesting xml: the Pronto does the request (it's just a HTTP GET), my HA app sends the response.

Image

Here you see that every page on the Pronto can have it's own script, executed periodically or only once when a page is shown.

When a page is not active on the Pronto, the associated script will not run and hence status information will not be retrieved. But it doesn't have to be, cause the page is not shown...

In my case, when i enter the page with the 4 buttons for the lighting in the livingroom, the status on the page is retrieved and the page is updated within .5 seconds. For now i let the "status update"-script run every 10 seconds.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Bwired » Sun Dec 30, 2007 12:41 am

OK got it. I think we will make some great scripts :-)
User avatar
Bwired
Administrator
Administrator
 
Posts: 5308
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Digit » Sun Dec 30, 2007 1:01 am

Great scripts.. yeah..

I'm already thinking about designing completely dynamically built pages.
I mean, whenever i add another light switch somewhere, i want everything to be adjusted as dynamically as possible. Define the new switch in your HA app and the rest follows without any work to be done. The website is built that way, so the same goes for the Pronto.

Image

For example, the labels above like 'Dressoir' and 'Laptop' are static right now; the number of buttons is also static. This is all design-time work. That shouldn't have to be like that. And it will not be! [8D]
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Bwired » Sun Dec 30, 2007 1:11 am

Agree make it generic, make a property in your HA system if the device should be Pronto enabled and with a Generic script it will be adjusted on the fly. If this is possible the scripting is strong enough.
User avatar
Bwired
Administrator
Administrator
 
Posts: 5308
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby Snelvuur » Sun Dec 30, 2007 11:21 am

@Digit: looks nice, this was also something i found to be usefull. My only issue is with using the extender i have to push a button first.. then it will react to me. As if its on standby. First click it on or something, and then it works. Seems to be only when using the extender.

// Erik (binkey.nl)
User avatar
Snelvuur
Forum Moderator
Forum Moderator
 
Posts: 3155
Joined: April 2007
Location: Netherlands

TSU9600 Tips & Tricks

Postby TANE » Mon Dec 31, 2007 11:49 am

Robert,
Design you have made looks great..:)
User avatar
TANE
Forum Moderator
Forum Moderator
 
Posts: 4806
Joined: April 2007
Location: Netherlands

TSU9600 Tips & Tricks

Postby Digit » Mon Dec 31, 2007 7:36 pm

I didn't want an ON and OFF button just to switch 1 device, and got my idea from a Instrumentation toolkit from IOComp i worked with before; they have nice-looking controls. Screencapture and PSP do the rest ;-)
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby TANE » Tue Jan 01, 2008 1:17 pm

Can you build something with the device name also in the button?
User avatar
TANE
Forum Moderator
Forum Moderator
 
Posts: 4806
Joined: April 2007
Location: Netherlands

TSU9600 Tips & Tricks

Postby Digit » Tue Jan 01, 2008 3:26 pm

The "ON" and "OFF" is done by setting the label of the button, the green is done by using different bitmaps. So the answer is yes, you can put any text you like in the button, as long as it fits. Just walk through the code and you can see how it's done. Even 2 lines (device name and status) should be possible by adding CR+LF in the label.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

TSU9600 Tips & Tricks

Postby TANE » Tue Jan 01, 2008 10:19 pm

Robert,
can you please send me the xcf file?
User avatar
TANE
Forum Moderator
Forum Moderator
 
Posts: 4806
Joined: April 2007
Location: Netherlands

TSU9600 Tips & Tricks

Postby Snelvuur » Tue Jan 01, 2008 11:19 pm

send me one too then ;-)

// Erik (binkey.nl)
User avatar
Snelvuur
Forum Moderator
Forum Moderator
 
Posts: 3155
Joined: April 2007
Location: Netherlands

Next

Return to Philips Pronto (TSU9600), IRtrans and other remotes

Who is online

Users browsing this forum: No registered users and 1 guest