Implement "SWRemote" as a Web Server Application

Have an idea for a new feature? Voice your opinion here.
Post Reply
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Implement "SWRemote" as a Web Server Application

Post by HB Guy »

Housebot's ability to create native "remote control" applications sets it apart from other home automation solutions. However, "native" implies a Windows-based operating system.

There are many low-cost, Internet Appliances with touch-sensitive screens (3Com Audrey, Nokia 770, etc) that would make excellent remote-controls but do not use a Microsoft operating system (derivations of Linux). The same is true for Internet-enabled cellphones. However, they all have web browsers that support JavaScript.

I propose a new feature that generates web pages using the information found in Themes. In effect, a Web Server Application would mimic the functionality of SWRemote. It would read Theme data and create web pages containing nothing more sophisticated than JavaScript (i.e. no Java, no Flash, nothing that needs plug-ins).

Most of the functionality found in a Theme has a comparable analogue in the web world (OK, not so sure about object transparency!). With some guidance from the Theme Editor (i.e. "this feature is not supported for web pages") one could make Themes that look and operate the same way when viewed with a PDA, Internet Appliance, or cell phone.
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Post by HB Guy »

Is the structure of a theme's XML file documented? If so, where can I find it?

I'd like to try my hand at building a .NET web application to convert a theme into a web page. I'm no expert but it seems there should be a way of creating an appropriate XSLT to convert the theme's XML into XHTML.
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

I've never documented it, because is really supposed to be just an internal file for the SWRemote.

However, with a little cyphering you can probably deduce the meanings of the properties. If you look at the property window for any particular control, each setting in the property dialog for that control will typically have an attribute in the XML for the setting. The attribute names are short to keep the file size down, but they kinda resemble what it is.

You can use the External Control plugin (like the ActiveX control) to make the requests, but you would need to periodically refresh to get the current status of things (if the panel had any status type controls).

Also might be tricky getting the images and dealing with the multiple state images in an image file. Another challenge would be that the XML defines devices, properties, tasks, etc. by their ID. Whereas the external control wants to work with the description.

Sounds like fun though ;)
Scott
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Post by HB Guy »

In lieu of the External Control plugin, would it not be possible to query HBdata.mdb directly? I noticed "P_ID=36" simply refers to record ID=36 in the Properties table ("Name=Power State").

I realize this technique may break if the schema changes in future versions but it's an expedient solution. The only problem I see is if Housebot opens the MDB in exclusive mode and locks out all other applications (I haven't tested this yet).

I don't know how SWRemote monitors properties (i.e. state changes) but it must be either:
1. SWRemote polls HouseBot
2. HouseBot broadcasts to SWRemote

If it is option #1, then the Web App will need to poll the MDB at least once every second (to properly update a System Time object). If option #2, then I'm out of luck unless you reveal the port address and protocol you're using to announce state changes.

*** OR ***
I can use the External Control to read/write a property, as Scott intended. :-)
However, I'd need to access the database directly to translate a "P_ID" into the property's name so that I can feed that to the External Control.

I suspect the External Control ensures all property changes are announced to Housebot. I noticed that if I change a property value directly (using Access), Housebot has no clue the property has changed (well, at least Housebot UI shows no evidence that the property was modified). I'm assuming it doesn't poll its own database but relies on "agents", like the External Control, to announce any modifications.

Flying on a wing and a prayer here ... whatever guidance you can offer would be appreciated!
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

HB Guy wrote:In lieu of the External Control plugin, would it not be possible to query HBdata.mdb directly?
Sure. You can always get anything you need from the database, as long as the HTTP server is on the HB machine. You also need to be a bit careful accessing the database concurrently with HB. Access/Jet doesn't handle concurrent access very well sometimes. You may be OK if you are just reading though.
I don't know how SWRemote monitors properties (i.e. state changes) but it must be either:
1. SWRemote polls HouseBot
2. HouseBot broadcasts to SWRemote
The server broadcasts changes to the remotes over the proprietary socket. You would need to just poll for status.

If you really wanted to get into it, you could create your own plugin (and not use the external control plugin) that communicates with the HTTP server or even directly with the client. That plugin can setup notifications with the HB server so it is informed whenever a Property Value changes. It could then send the notification to anyone who wants to know.
I can use the External Control to read/write a property, as Scott intended. :-)
However, I'd need to access the database directly to translate a "P_ID" into the property's name so that I can feed that to the External Control.
That's probably what I would suggest. Just open the DB when starting and create a table that maps the Devices, Property, Tasks, etc. descriptions to their IDs.
I suspect the External Control ensures all property changes are announced to Housebot. I noticed that if I change a property value directly (using Access), Housebot has no clue the property has changed (well, at least Housebot UI shows no evidence that the property was modified). I'm assuming it doesn't poll its own database but relies on "agents", like the External Control, to announce any modifications.
Don't update stuff in the database. Just use it for read-only. If you update something, HB won't recognize the update AND it may even overwrite your change. The External Control device will manage it safely.
Scott
HB Guy
Member
Posts: 36
Joined: Fri Jun 30, 2006 3:52 pm
Location: Montréal, QC

Post by HB Guy »

Thanks Scott!

My initial strategy will be based on the following:

1. Read HBdata.mdb for the sole purpose of translating Theme codes (i.e. "P_ID") into Device, Property, Task, etc.
2. Use the External Control Device for all read/write operations.

I can hardly wait to see a Theme rendered as a web page!
Post Reply