Class: Insnergy::Widget

Inherits:
Object
  • Object
show all
Defined in:
lib/insnergy-api-ruby-client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Widget

Returns a new instance of Widget.



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/insnergy-api-ruby-client.rb', line 127

def initialize(opts = {})
  @infos = Hash.new
  @new_infos = Hash.new
  @widget_dev_id = opts['dev_id']
  @widget_dev_type_name = opts['dev_type_name']
  @widget_alias = opts['alias']
  @widget_status = opts['status']
  opts['widget_infos'].each do |ele|
    @new_infos[ele['info_desc']] = { id: ele['info_id'], name: ele['info_name'], value: ele['info_value']}
    @infos[ele['info_name']] = ele['info_value']
  end
end

Instance Attribute Details

#new_infosObject (readonly)

Returns the value of attribute new_infos.



125
126
127
# File 'lib/insnergy-api-ruby-client.rb', line 125

def new_infos
  @new_infos
end

#widget_aliasObject (readonly)

Returns the value of attribute widget_alias.



125
126
127
# File 'lib/insnergy-api-ruby-client.rb', line 125

def widget_alias
  @widget_alias
end

#widget_dev_idObject (readonly)

Returns the value of attribute widget_dev_id.



125
126
127
# File 'lib/insnergy-api-ruby-client.rb', line 125

def widget_dev_id
  @widget_dev_id
end

#widget_dev_type_nameObject (readonly)

Returns the value of attribute widget_dev_type_name.



125
126
127
# File 'lib/insnergy-api-ruby-client.rb', line 125

def widget_dev_type_name
  @widget_dev_type_name
end

#widget_statusObject (readonly)

Returns the value of attribute widget_status.



125
126
127
# File 'lib/insnergy-api-ruby-client.rb', line 125

def widget_status
  @widget_status
end

Instance Method Details

#co2_meterObject



148
149
150
# File 'lib/insnergy-api-ruby-client.rb', line 148

def co2_meter
  @infos['400600']
end

#co_meterObject



144
145
146
# File 'lib/insnergy-api-ruby-client.rb', line 144

def co_meter
  @infos['400700']
end

#sensor_th_hyObject



152
153
154
# File 'lib/insnergy-api-ruby-client.rb', line 152

def sensor_th_hy
  "#{@infos['400100']}|#{@infos['400200']}"
end

#widget_info_valueObject



140
141
142
# File 'lib/insnergy-api-ruby-client.rb', line 140

def widget_info_value
  self.send(:"#{@widget_dev_type_name.downcase}")
end