Venstar Query Info

The first of the three (info, control and runtimes) Venstar projects that I’ll discuss is the query info, discussing how to enable HCA to query the Venstar and record and/or act upon the responses.  The Venstar query/info will provide you with 19 (if I’ve counted right) current settings of the Venstar.  Most of these are of little importance, at least to me. But 5 of the 19 are of some value: heat and cool setpoints, current operation, current mode and current temperature.

This project is made up of the following components:

  • A program in HCA which initiates the query.
  • A Perl program that sends out the appropriate command, parses the response and places HCA flags into a text file.
  • A Venstar T5800 with the API enabled.
  • A program in HCA which reads the flags from the text file.
  • Follow-on HCA programs that take actions based upon the value of the flags.

Before we get into each of the above components, here’s an overall picture of the HCA program that collects both the info and runtimes from the Venstar. The first horizontal line of 6 blocks is for the query/info and the second is the query/runtimes. They are identical, except for the instructions inside the boxes. The “extra” box at the bottom is where all the data from both queries is written out to a log file.

HCA Initiates the Query

In my case, the program shown above is started once per day using the HCA scheduler. The query/info is the topic of this posting, so we’ll concentrate on the first line of 6 boxes. Here’s just that line.

The first box is a “compute” and is used to set the HCA flags back to zero so I’ll know if the query has failed for some reason. Inside the compute box are the following 6 instructions: vencoolset = 0; vencurrtemp = 0; venheatset = 0; venmode = 0; venstate = 0; venqstatus = 9;. You can probably guess their meanings, or you can look at the Venstar API documentation. The venqstatus holds the status and will be changed depending on what went right/wrong. As examples, here’s my current flags: venheatset=59.0, vencoolset=82.0, vencurrtemp=63.0, venmode=1, venstate=0, venqstatus=0.

The second box executes an external (to HCA) program or bat file and contains the following.

Note that it starts the Perl interpreter, sets the directory where all these files exist, and finally names the Perl program that will create the query (to be explained below) and handle the response.

The third box is a 10-second delay, allowing time for the Perl program to issue the query and the Venstar to reply.

Perl Sends out the Query and Handles the Response

The Perl program is listed in this posting. Some more API background. The Perl program issues the query and awaits the response. It takes the response and formats it to a “nicer” format and moves all the responses into a hash. From the hash it updates the venreport file, where it writes the flags mentioned above so HCA can read them. There’s also a flag to indicate things finished ok (or didn’t), venqstatus.

A Venstar T5800 With the API Enabled

Not much to say here that hasn’t already been said here.

HCA Reads the File With the Flags

The fourth box (the spyglass) is a “read data file” operation. In it you specify the file to be read (venreport.txt), and HCA assumes that file contains flags. In this project, the Perl program above just created this file with the 6 flags mentioned above.

The fifth and sixth boxes are used to see if the venqstatus comes back with anything not zero, and sends me an email if so.

Do Something With the Data

After the data, in the form of flags, has been imported into HCA there’s all sorts of things you could do. In my case I am simply logging this information to an external logfile from where I can send it to a web page or an email as desired. The execute external program box at the bottom does this.The inside of that box looks like:

I execute the Windows command line, set the folder to the same place as always, and then do an “echo” that writes a series of labels and flags out to a file. That entire line looks like: /c echo %_now()% Hsp %venheatset% Csp %vencoolset% Tcur %vencurrtemp% Mode %venmode% St %venstate% RT %venheat1run% TS %venrunts% >> venYS%yearnumber%%monthnumber%.txt. You can see that it contains data from both the query/info (the first 6 blocks of this HCA program) and the query/runtimes (the second 6 blocks).

As In Various and Sundry