Class: Sunscout::SolarLog::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sunscout/solar_log/client.rb

Overview

Low-level binding to the SolarLog HTTP API

Examples:

Basic usage

require 'sunscout'
c = Sunscout::SolarLog::Client.new('http://10.60.1.10')
data = c.get_data()
puts "Current power output: #{ data[:power_ac] }W"

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Client

Initialize a new instance of the class.

Parameters:

  • host (String)

    URI of the SolarLog web interface.



21
22
23
# File 'lib/sunscout/solar_log/client.rb', line 21

def initialize(host)
  @host = host
end

Instance Method Details

#get_dataHash<Symbol, String|Integer>

Retrieve data from the HTTP API.

Returns:

  • (Hash<Symbol, String|Integer>)

    Hash containing retrieved data



27
28
29
30
31
32
33
# File 'lib/sunscout/solar_log/client.rb', line 27

def get_data
  uri = build_uri
  req = build_request(uri)
  data = send_request(req, uri)

  data
end