class Solarium::Collector

Public: Collects generation information from the Envoy API.

Attributes

error[R]

 Public: Either an exception that was thrown during collection or nil.

lifetime[R]

Public: The number of watt hours which have been generated since the system was installed.

now[R]

Public: The number of watts currently being generated.

today[R]

Public: The number of watt hours which have been generated today.

week[R]

Public: The number of watt hours which have been generated in the last week.

Public Class Methods

new(url) click to toggle source

Public: Initializes a new instance of the Solarium::Collector class.

url - The URL of the Envoy web interface.

# File lib/solarium/collector.rb, line 26
def initialize url
        collect url
rescue ::Exception => error
        @error = error
end

Private Instance Methods

collect(url) click to toggle source

Internal: Collects generation information from the Envoy API.

url - The URL of the Envoy web interface.

# File lib/solarium/collector.rb, line 35
        def collect url
        uri = URI.parse url
        uri.path = '/api/v1/production'

        body = open(uri).read
        json = JSON.parse body

        @now      = json['wattsNow']
        @today    = json['wattHoursToday']
        @week     = json['wattHoursSevenDays']
        @lifetime = json['wattHoursLifetime']
end