Class: Fritzbox::Smarthome::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/fritzbox/smarthome/resource.rb

Direct Known Subclasses

Actor

Class Method Summary collapse

Class Method Details

.get(command:, ain: nil, param: nil, **params) ⇒ Object

Parameters:

  • params (Hash)

    key/value pairs that will be appended to the switchcmd query string



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fritzbox/smarthome/resource.rb', line 6

def get(command:, ain: nil, param: nil, **params)
  url = "#{config.endpoint}/webservices/homeautoswitch.lua?switchcmd=#{command}&sid=#{authenticate}"
  url = "#{url}&ain=#{ain}"     if ain.present?
  url = "#{url}&param=#{param}" if param.present?

  params.each_with_object(url) do |(key, value)|
    url = "#{url}&#{key}=#{value}"
  end

  config.logger.debug(url)

  HTTParty.get(url, **httparty_options)
end

.parse(response) ⇒ Object



20
21
22
# File 'lib/fritzbox/smarthome/resource.rb', line 20

def parse(response)
  nori.parse(response.body)
end