{"id":386,"date":"2020-03-30T20:34:10","date_gmt":"2020-03-31T01:34:10","guid":{"rendered":"https:\/\/sundrysites.com\/?page_id=386"},"modified":"2020-03-31T09:23:31","modified_gmt":"2020-03-31T14:23:31","slug":"venstar-api-documentation","status":"publish","type":"page","link":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/","title":{"rendered":"Venstar API Documentation"},"content":{"rendered":"\n<p>Venstar had <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/sundrysites.com\/wp-content\/uploads\/vennstar-api.pdf\" target=\"_blank\">a short description<\/a> of the API posted on their web site (8 pages), but it needs a little further explanation.\u00a0 Another issue is that Venstars have been at API V4 for several years now, but the documentation reads V3.\u00a0 Fortunately I haven&#8217;t noticed any major differences between what the doc says and what I actually see on the network.<\/p>\n\n\n\n<p>You can get a good idea of the 5 available queries (root, info, sensors, runtimes and alerts) by entering the IP address of the Venstar followed by the query.&nbsp; As an example, for a Venstar at 192.168.2.148, if I type &#8220;192.168.2.148\/query\/info&#8221; into the web browser&#8217;s url window I will get a JSON-formatted response that looks pretty much like what section 3.1.1 of their documentation shows.&nbsp; The control function is quite different and I know of no way to just type the url to issue a control command.<\/p>\n\n\n\n<p>Fortunately, Perl provides good capabilities to both issue the commands and handle the responses.&nbsp; As an example, the following Perl code will issue a proper query and place the response into $resp.<\/p>\n\n\n\n<p>my $ua = new LWP::UserAgent;<br>my $req = new HTTP::Request &#8216;GET&#8217;,&#8217;http:\/\/192.168.2.148\/query\/info&#8217;;<br>my $resp = $ua -&gt; request($req);<\/p>\n\n\n\n<p>To issue a control, the Perl code is somewhat different.<\/p>\n\n\n\n<p>my $ua = new LWP::UserAgent;<br>my $req = new HTTP::Request &#8216;POST&#8217;,&#8217;http:\/\/192.168.2.148\/control&#8217;;<br>$req-&gt;header(&#8216;content-type&#8217; =&gt; &#8216;application\/x-www-form-urlencoded&#8217;);<br>my $query = &#8220;heattemp=&#8221; . $heattemp . &#8220;&amp;&#8221; . &#8220;cooltemp=&#8221; . $cooltemp;<br>$req-&gt;content($query);<br>my $resp = $ua -&gt; request($req);<\/p>\n\n\n\n<p>In the case of the control, there isn&#8217;t much of a response to handle.&nbsp; For the queries, handling the response becomes critical.&nbsp; Perl does have a JSON parser but after looking at the text of the responses I decided it would be easier to handle them without using it.&nbsp; I first remove any header (luckily fixed length), then remove all the brackets, braces and quotes from the response.&nbsp; I then use commas and colons to split the remaining message into elements of an array(for the runtimes) or a hash(for the info).&nbsp; I have posted complete samples of the Perl code to handle the <a href=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/\">info<\/a> and the <a href=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-runtimes-perl-program\/\">runtimes<\/a>.<\/p>\n\n\n\n<p><strong>RUNTIMES<\/strong><\/p>\n\n\n\n<p>The response that needs a fair amount of explanation is the one I cared about the most &#8211; the query\/runtimes.&nbsp; Venstar&#8217;s documentation on the runtimes mentions the content-length is 56 but only shows 8 &#8211; well, it shows 9 but the last one is an either\/or.&nbsp; What they don&#8217;t say is that each response includes all the daily runtimes for the previous 6 days plus a 7th runtime for today, and 7 times 8 makes up the 56.&nbsp; The runtimes for the 6 previous days are based on a 24-hour period that ended at midnight.&nbsp; If you look at the runtimes on Skyport you&#8217;ll see the previous 6 days (along with the previous week&#8217;s runtimes) plus whatever the runtime is for that day, and if you use your browser to look at the response itself you&#8217;ll see where those numbers came from.&nbsp; In the packet itself the days are ordered in chronological order, with the current (incomplete) day being last.&nbsp; Further complicating this is that for the first 6 days of operation there are fewer than the 6 + 1 days.<\/p>\n\n\n\n<p>If you&#8217;ve been successful at retrieving the runtimes every day for the previous 6 days, the only new runtime you care about is the 6th one out of the 7.&nbsp; You don&#8217;t care about 1 through 5 because you&#8217;ve already seen them, and the 7th\/last one is always for an incomplete day.&nbsp; As each day passes the runtimes for a particular day advance in the response until they drop off the leading edge.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Venstar had a short description of the API posted on their web site (8 pages), but it needs a little further explanation.\u00a0 Another issue is that Venstars have been at API V4 for several years now, but the documentation reads V3.\u00a0 Fortunately I haven&#8217;t noticed any major differences between what the doc says and what &hellip; <a href=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Venstar API Documentation<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":384,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-386","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Venstar API Documentation - Sundrysites<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Venstar API Documentation - Sundrysites\" \/>\n<meta property=\"og:description\" content=\"Venstar had a short description of the API posted on their web site (8 pages), but it needs a little further explanation.\u00a0 Another issue is that Venstars have been at API V4 for several years now, but the documentation reads V3.\u00a0 Fortunately I haven&#8217;t noticed any major differences between what the doc says and what &hellip; Continue reading Venstar API Documentation &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/\" \/>\n<meta property=\"og:site_name\" content=\"Sundrysites\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-31T14:23:31+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/venstar\\\/venstar-api-documentation\\\/\",\"url\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/venstar\\\/venstar-api-documentation\\\/\",\"name\":\"Venstar API Documentation - Sundrysites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sundrysites.com\\\/#website\"},\"datePublished\":\"2020-03-31T01:34:10+00:00\",\"dateModified\":\"2020-03-31T14:23:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/venstar\\\/venstar-api-documentation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/venstar\\\/venstar-api-documentation\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/venstar\\\/venstar-api-documentation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sundrysites.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Home Info\",\"item\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Arduino Projects\",\"item\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Venstar\",\"item\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/venstar\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Venstar API Documentation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sundrysites.com\\\/#website\",\"url\":\"https:\\\/\\\/sundrysites.com\\\/\",\"name\":\"Sundrysites\",\"description\":\"As In Various and Sundry\",\"publisher\":{\"@id\":\"https:\\\/\\\/sundrysites.com\\\/#\\\/schema\\\/person\\\/1e11ce6af1587a3431e57dfc0797ab61\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sundrysites.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/sundrysites.com\\\/#\\\/schema\\\/person\\\/1e11ce6af1587a3431e57dfc0797ab61\",\"name\":\"Wayne Gulden\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g\",\"caption\":\"Wayne Gulden\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/sundrysites.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Venstar API Documentation - Sundrysites","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/","og_locale":"en_US","og_type":"article","og_title":"Venstar API Documentation - Sundrysites","og_description":"Venstar had a short description of the API posted on their web site (8 pages), but it needs a little further explanation.\u00a0 Another issue is that Venstars have been at API V4 for several years now, but the documentation reads V3.\u00a0 Fortunately I haven&#8217;t noticed any major differences between what the doc says and what &hellip; Continue reading Venstar API Documentation &rarr;","og_url":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/","og_site_name":"Sundrysites","article_modified_time":"2020-03-31T14:23:31+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/","url":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/","name":"Venstar API Documentation - Sundrysites","isPartOf":{"@id":"https:\/\/sundrysites.com\/#website"},"datePublished":"2020-03-31T01:34:10+00:00","dateModified":"2020-03-31T14:23:31+00:00","breadcrumb":{"@id":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/venstar-api-documentation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sundrysites.com\/"},{"@type":"ListItem","position":2,"name":"Home Info","item":"https:\/\/sundrysites.com\/index.php\/home-info\/"},{"@type":"ListItem","position":3,"name":"Arduino Projects","item":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/"},{"@type":"ListItem","position":4,"name":"Venstar","item":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/venstar\/"},{"@type":"ListItem","position":5,"name":"Venstar API Documentation"}]},{"@type":"WebSite","@id":"https:\/\/sundrysites.com\/#website","url":"https:\/\/sundrysites.com\/","name":"Sundrysites","description":"As In Various and Sundry","publisher":{"@id":"https:\/\/sundrysites.com\/#\/schema\/person\/1e11ce6af1587a3431e57dfc0797ab61"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sundrysites.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/sundrysites.com\/#\/schema\/person\/1e11ce6af1587a3431e57dfc0797ab61","name":"Wayne Gulden","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g","caption":"Wayne Gulden"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/c0392cdfb7826ed5407aad362998bc6dd03fe293560ce15ccc2211357e3cec6e?s=96&d=mm&r=g"},"sameAs":["https:\/\/sundrysites.com"]}]}},"_links":{"self":[{"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/comments?post=386"}],"version-history":[{"count":3,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/386\/revisions"}],"predecessor-version":[{"id":485,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/386\/revisions\/485"}],"up":[{"embeddable":true,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/384"}],"wp:attachment":[{"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/media?parent=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}