The second of the three (info, control and runtimes) Venstar projects that I’ll discuss is the control, discussing how to enable HCA to control the Venstar, doing such things as setting the mode, fan operation, heat point and cool point.
This project is made up of the following components:
- A program in HCA which initiates the control.
- A Perl program that sends out the appropriate command and lets HCA know if it was received.
- A Venstar T5800 with the API enabled.
The Venstar T5800 is fully programmable and can be controlled from the Skyport web site as well. So there’s no compelling reason to have HCA also control it. Still, I can think of times when it would be useful and this project has the details.
Per section 3.2 of Venstar’s API reference there are 3 main things you can control: mode (auto, heat, cool, off), fan (auto, on) and the heat/cool set points. Instead of a straight-forward http request you now must use an http post that is url encoded. Luckily Perl is able to do this with little effort.
HCA Initiates the Control
For whatever you want to control you must first set up an HCA flag. In my example, I only control the heat and cool set points, so I have just two flags: vennewhsp and vennewcsp. Just defining them in a compute box is sufficient to create them. In the compute box you’d have one or more statements like: vennewhsp = 72;. Once the appropriate flags are set to their desired values you use the execute external program box, which looks like:
The first line calls the Perl interpreter, the second sets the folder where all the files reside. The third line is the most interesting: venstar-control.pl %vennewhsp% %vennewcsp%. It names the Perl script that sends the control along with 2 parameters – the flags (enclosed in %’s) as mentioned above.
Perl Sends the Control
The Perl program, listed here, picks the values of the flags up as arguments in order – so you must be careful to line them up. It issues the control and awaits a response, setting a flag to indicate success. If you wanted to check this response with HCA you’d write the flag to a file that HCA would subsequently read – see the query/info posting to get an idea of how this is done.
The Venstar with its API Enabled
There’s not much to add to this posting.