Sha256: 0a811437be2277024ccfcec95df6a0d1da3adcdef56ff27ad528ca8471609717

Contents?: true

Size: 997 Bytes

Versions: 2

Compression:

Stored size: 997 Bytes

Contents

require 'renstar'
require 'optparse'
require 'ostruct'
require 'pry'

options = {}

#DEFAULT_OPTIONS = { all: false }.freeze


USAGE = " Usage: renstar.rb command [value]"

OptionParser.new do |opts|

  opts.banner = USAGE

  opts.on '-d', '--discover', 'Discover all Renstar devices' do |d|
    options[:discover] = true
  end

  opts.on '-h', '--help', 'Display this screen' do |h|
    puts opts
    exit 0
  end
end.parse!

if options[:discover]
  thermos = Renstar::Thermostat.search
  thermos.each do |thermo|
    puts "Found: #{thermo.location} #{thermo.usn}"
  end
  exit 0
end


thermos = Renstar::Thermostat.search
thermos.each do |thermo|
  puts "Found: #{thermo.location} #{thermo.usn}"
end
puts "Using: " + thermos.first.location + " - " + thermos.first.usn
unless (ARGV.nil? || ARGV.empty?)
  response = thermos.first.send(*ARGV)
  case response
  when String
    puts response
  when Renstar::APIClient::APIObject
    response.pp
  when Array
    response.each {|x| x.pp }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
renstar-0.3.1 bin/renstar.rb
renstar-0.3.0 bin/renstar.rb