Venstar Query Runtimes

The third of the three (info, control and runtimes) Venstar projects that I’ll discuss is the query runtimes, discussing how to enable HCA to query the Venstar and record and/or act upon the responses.  The Venstar query/runtimes will provide you with the last 7 days of runtimes for a variety of heating and cooling counters.  I posted on the runtimes’ API and more information is contained in Venstar’s documentation.

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/runtimes is the topic of this posting, so we’ll concentrate on the second 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 three instructions: venheat1run = 0; venrunts = 0; venrstatus = 9;. The venheat1run flag holds the run time of the furnace in minutes for the day that just ended while the venrunts flag holds the time stamp for that day.  The venrstatus holds the status and will be changed depending on what went right/wrong.  As examples, here’s my current flags: venrunts=160103, venheat1run=244 and venrstatus = 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 postingSome more API background.  There are 3 types of files that it handles: (1)  venruntimes.txt, where it writes the two flags mentioned above so HCA can read them, (2) venrunlog.txt, where it writes the relatively unformatted Venstar response, and (3) venworkh1xx.txt, which holds a year’s worth of runtime data, and the “xx” is the year.  The program actually opens up 2 year’s worth of runtime data, just to cover the Venstar responses during the first week of the new year.

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 an array.  From the array it updates the yearly runtime file(s) and places the HCA flags into the venruntimes file.  There’s also a flag to indicate things finished ok (or didn’t), venrstatus.

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 (venruntimes.txt), and HCA assumes that file contains flags.  In this project, the Perl program above just created this file with 4 flags (the 3 mentioned above plus a cool1 flag that I don’t use).

The fifth and sixth boxes are used to see if the venrstatus 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 (to HCA) logfile (in addition to the venrunlog.txt file mentioned above) from where I can send it to a web page or an email as desired.  The execute external program box at the bottom looks like: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