module Domoticz

Constants

VERSION

Public Class Methods

configuration() click to toggle source
# File lib/domoticz.rb, line 7
def self.configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/domoticz.rb, line 11
def self.configure
  yield(configuration) if block_given?
end
perform_api_request(params) click to toggle source
# File lib/domoticz.rb, line 19
def self.perform_api_request(params)
  username = Domoticz.configuration.username
  password = Domoticz.configuration.password

  uri = URI(Domoticz.configuration.server + "json.htm?" + params)
  request = Net::HTTP::Get.new(uri)
  request.basic_auth(username, password) if username && password
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }

  JSON.parse(response.body)
end
reset() click to toggle source
# File lib/domoticz.rb, line 15
def self.reset
  @configuration = Configuration.new
end