I’ve got a nifty Venstar thermostat that hooks up to the wifi so I can control it from the Venstar mobile app. The app works fine, and uses a cloud service so you don’t have to be on local wifi, but I wanted direct control of it from my LAN.

It turns out the good people at Venstar provide documentation for their local API. You will need to enable the “Local API” on your thermostat before this library will work.

Install the gem

Let’s start by installing the gem:

gem install renstar

I recommend loading the library in irb or pry (I use pry) so we can interact with the receiver:

gem install pry
pry

We of course have to load our gem, you can do it with this:

require 'renstar'

Find a thermostat on the network

The gem can leverage SSDP discover your thermostats and return Thermostat objects that will let us easily control them. The search method returns an array of found thermostats. We’re just going to take the first one:

thermo = Renstar::Thermostat.search.first

Controlling the Thermostat

Now that we have our Thermostat object, we can easily control it:

Heat to 80 degrees:

thermo.heat(80)

Cool to 60 degrees:

thermo.cool(60)

Automatically keep the temp between 70 and 74 degrees:

thermo.auto(70, 74)

Turn off heating and/or cooling

thermo.off

Control the fan:

thermo.fan_on

thermo.fan_off

thermo.fan_toggle

Control the schedule:

thermo.schedule_on

thermo.schedule_off

thermo.schedule_toggle

Set Home/Away:

thermo.home

thermo.away

Check out the renstar gem on github and submit a PR!