Class: Sensor

Inherits:
Object
  • Object
show all
Defined in:
lib/lights/sensor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, data = {}) ⇒ Sensor

Returns a new instance of Sensor.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/lights/sensor.rb', line 39

def initialize( id, data = {} )
  @id = id
  @data = data
  @name = data["name"]
  @type = data["type"]
  @model_id = data["modelid"]
  @manufacturer_name = data["manufacturername"]
  @unique_id = data["uniqueid"]
  @sw_version = data["swversion"]
  @state = SensorState.new(data["state"])
  #@config = SensorConfig.new(data["config"])
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def id
  @id
end

#manufacturer_nameObject (readonly)

Returns the value of attribute manufacturer_name.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def manufacturer_name
  @manufacturer_name
end

#model_idObject (readonly)

Returns the value of attribute model_id.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def model_id
  @model_id
end

#nameObject (readonly)

Returns the value of attribute name.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def name
  @name
end

#stateObject (readonly)

Returns the value of attribute state.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def state
  @state
end

#sw_versionObject (readonly)

Returns the value of attribute sw_version.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def sw_version
  @sw_version
end

#typeObject (readonly)

Returns the value of attribute type.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def type
  @type
end

#unique_idObject (readonly)

Returns the value of attribute unique_id.



38
39
40
# File 'lib/lights/sensor.rb', line 38

def unique_id
  @unique_id
end

Instance Method Details

#to_json(options = {}) ⇒ Object



64
65
66
# File 'lib/lights/sensor.rb', line 64

def to_json(options={})
  data.to_json
end