{"id":368,"date":"2020-03-30T20:17:30","date_gmt":"2020-03-31T01:17:30","guid":{"rendered":"https:\/\/sundrysites.com\/?page_id=368"},"modified":"2020-03-30T20:17:30","modified_gmt":"2020-03-31T01:17:30","slug":"venstar-status-perl-program","status":"publish","type":"page","link":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/","title":{"rendered":"Venstar Status Perl Program"},"content":{"rendered":"\n<p>The Venstar thermostat has a little-known API (application programming interface) that one can use to control and query it.&nbsp; This Perl program gets the current status of the Venstar and reports it to HCA.<\/p>\n\n\n\n<p>use LWP::UserAgent;<br># use Data::Dumper;<br># set initial values for hca flag values<br>my $heattemp = &#8220;0&#8221;;<br>my $cooltemp = &#8220;0&#8221;;<br>my $spacetemp = &#8220;0&#8221;;<br>my $venmode = &#8220;0&#8221;;<br>my $venstate = &#8220;0&#8221;;<br>my $venstatus = &#8220;0&#8221;; # use to report status of inquiry<br># set up xfer file<br>my $outfile = &#8220;venreport.txt&#8221;;&nbsp; #picked up by hca<br>my $outln = &#8220;&#8221;;<br># create user agent and request for venstar<br>my $ua = new LWP::UserAgent;<br>my $req = new HTTP::Request &#8216;GET&#8217;,&#8217;http:\/\/192.168.2.148\/query\/info&#8217;;<br># fetch info from venstar<br>my $resp = $ua -&gt; request($req);<br># see if it ended ok<br>if ($resp-&gt;is_success) {<br>my $message = $resp-&gt;decoded_content;<br>#&nbsp;&nbsp;&nbsp; print &#8220;Received reply: $message\\n&#8221;;<br># remove quotes and brackets from venstar decoded response<br>$message =~ tr\/&#8221;\/\/d;<br>$message =~ tr\/{\/\/d;<br>$message =~ tr\/}\/\/d;<br>#&nbsp;&nbsp; &nbsp;print &#8220;tempmsg: $message\\n&#8221;;<br># create a hash out of the remaining string<br>my %venhash = split \/[,:]\/, $message;<br># pull out values of interest from hash<br>$heattemp = $venhash{&#8220;heattemp&#8221;};<br>$cooltemp = $venhash{&#8220;cooltemp&#8221;};<br>$spacetemp = $venhash{&#8220;spacetemp&#8221;};<br>$venmode = $venhash{&#8220;mode&#8221;};<br>$venstate = $venhash{&#8220;state&#8221;};<br>#&nbsp;&nbsp; &nbsp;print Dumper \\%venhash;<br>#&nbsp;&nbsp; &nbsp;print &#8220;heattemp: $heattemp\\n&#8221;;<br>$venstatus = &#8220;0&#8221;;&nbsp; # indicate success to hca<br>$thisline = &#8220;venheatset=&#8221; . $heattemp . &#8220;\\n&#8221;;<br>$outln = $outln . $thisline;<br>$thisline = &#8220;vencoolset=&#8221; . $cooltemp . &#8220;\\n&#8221;;<br>$outln = $outln . $thisline;<br>$thisline = &#8220;vencurrtemp=&#8221; . $spacetemp . &#8220;\\n&#8221;;<br>$outln = $outln . $thisline;<br>$thisline = &#8220;venmode=&#8221; . $venmode . &#8220;\\n&#8221;;<br>$outln = $outln . $thisline;<br>$thisline = &#8220;venstate=&#8221; . $venstate . &#8220;\\n&#8221;;<br>$outln = $outln . $thisline;<br>$thisline = &#8220;venqstatus=&#8221; . $venstatus . &#8220;\\n&#8221;;<br>$outln = $outln . $thisline;<br>}<br>else {<br>#&nbsp;&nbsp;&nbsp; print &#8220;HTTP POST error code: &#8220;, $resp-&gt;code, &#8220;\\n&#8221;;<br>#&nbsp;&nbsp;&nbsp; print &#8220;HTTP POST error message: &#8220;, $resp-&gt;message, &#8220;\\n&#8221;;<br>$venstatus = &#8220;1&#8221;;&nbsp; # indicate failure to hca<br>$outln = &#8220;venqstatus=&#8221; . $venstatus . &#8220;\\n&#8221;;<br>}<br># either good or not, build hca file<br>open OUTPUT, &#8220;&gt; $outfile&#8221; or die &#8220;Output file open error: $!&#8221;;<br>print OUTPUT $outln;<br>close OUTPUT;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Venstar thermostat has a little-known API (application programming interface) that one can use to control and query it.&nbsp; This Perl program gets the current status of the Venstar and reports it to HCA. use LWP::UserAgent;# use Data::Dumper;# set initial values for hca flag valuesmy $heattemp = &#8220;0&#8221;;my $cooltemp = &#8220;0&#8221;;my $spacetemp = &#8220;0&#8221;;my $venmode &hellip; <a href=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Venstar Status Perl Program<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":352,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-368","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 Status Perl Program - 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\/perl-programs\/venstar-status-perl-program\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Venstar Status Perl Program - Sundrysites\" \/>\n<meta property=\"og:description\" content=\"The Venstar thermostat has a little-known API (application programming interface) that one can use to control and query it.&nbsp; This Perl program gets the current status of the Venstar and reports it to HCA. use LWP::UserAgent;# use Data::Dumper;# set initial values for hca flag valuesmy $heattemp = &#8220;0&#8221;;my $cooltemp = &#8220;0&#8221;;my $spacetemp = &#8220;0&#8221;;my $venmode &hellip; Continue reading Venstar Status Perl Program &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/\" \/>\n<meta property=\"og:site_name\" content=\"Sundrysites\" \/>\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=\"2 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\\\/perl-programs\\\/venstar-status-perl-program\\\/\",\"url\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/perl-programs\\\/venstar-status-perl-program\\\/\",\"name\":\"Venstar Status Perl Program - Sundrysites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sundrysites.com\\\/#website\"},\"datePublished\":\"2020-03-31T01:17:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/perl-programs\\\/venstar-status-perl-program\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/perl-programs\\\/venstar-status-perl-program\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/perl-programs\\\/venstar-status-perl-program\\\/#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\":\"Perl Programs\",\"item\":\"https:\\\/\\\/sundrysites.com\\\/index.php\\\/home-info\\\/arduino-projects\\\/perl-programs\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Venstar Status Perl Program\"}]},{\"@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 Status Perl Program - 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\/perl-programs\/venstar-status-perl-program\/","og_locale":"en_US","og_type":"article","og_title":"Venstar Status Perl Program - Sundrysites","og_description":"The Venstar thermostat has a little-known API (application programming interface) that one can use to control and query it.&nbsp; This Perl program gets the current status of the Venstar and reports it to HCA. use LWP::UserAgent;# use Data::Dumper;# set initial values for hca flag valuesmy $heattemp = &#8220;0&#8221;;my $cooltemp = &#8220;0&#8221;;my $spacetemp = &#8220;0&#8221;;my $venmode &hellip; Continue reading Venstar Status Perl Program &rarr;","og_url":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/","og_site_name":"Sundrysites","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/","url":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/","name":"Venstar Status Perl Program - Sundrysites","isPartOf":{"@id":"https:\/\/sundrysites.com\/#website"},"datePublished":"2020-03-31T01:17:30+00:00","breadcrumb":{"@id":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/venstar-status-perl-program\/#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":"Perl Programs","item":"https:\/\/sundrysites.com\/index.php\/home-info\/arduino-projects\/perl-programs\/"},{"@type":"ListItem","position":5,"name":"Venstar Status Perl Program"}]},{"@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\/368","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=368"}],"version-history":[{"count":1,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/368\/revisions"}],"predecessor-version":[{"id":369,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/368\/revisions\/369"}],"up":[{"embeddable":true,"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/pages\/352"}],"wp:attachment":[{"href":"https:\/\/sundrysites.com\/index.php\/wp-json\/wp\/v2\/media?parent=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}