class Domoticz::Device
Attributes
data[RW]
idx[RW]
Public Class Methods
all()
click to toggle source
# File lib/domoticz/device.rb, line 45 def self.all Domoticz.perform_api_request("type=devices&filter=all&used=true")["result"].map do |json| Device.new_from_json(json) end end
find_by_id(id)
click to toggle source
# File lib/domoticz/device.rb, line 41 def self.find_by_id(id) all.find { |d| d.idx == id.to_s } end
new_from_json(json)
click to toggle source
# File lib/domoticz/device.rb, line 51 def self.new_from_json(json) device = self.new device.data = json device.idx = json["idx"] device end
Public Instance Methods
dimmer?()
click to toggle source
# File lib/domoticz/device.rb, line 26 def dimmer? isDimmer end
method_missing(method_sym, *arguments, &block)
click to toggle source
Calls superclass method
# File lib/domoticz/device.rb, line 30 def method_missing(method_sym, *arguments, &block) hash = Hash[@data.map { |k, v| [k.downcase, v] }] key = method_sym.to_s.downcase if hash.has_key?(key) hash[key] else super end end
off!()
click to toggle source
# File lib/domoticz/device.rb, line 14 def off! Domoticz.perform_api_request("type=command¶m=switchlight&idx=#{idx}&switchcmd=Off") end
on!()
click to toggle source
# File lib/domoticz/device.rb, line 10 def on! Domoticz.perform_api_request("type=command¶m=switchlight&idx=#{idx}&switchcmd=On") end
seconds_since_update()
click to toggle source
# File lib/domoticz/device.rb, line 6 def seconds_since_update Time.now - Time.parse(lastupdate) end
temperature()
click to toggle source
# File lib/domoticz/device.rb, line 22 def temperature temp end
toggle!()
click to toggle source
# File lib/domoticz/device.rb, line 18 def toggle! Domoticz.perform_api_request("type=command¶m=switchlight&idx=#{idx}&switchcmd=Toggle") end