Class: SAAL::Denkovi::Outlet

Inherits:
SensorUnderlying show all
Defined in:
lib/denkovi.rb

Instance Method Summary collapse

Methods inherited from SensorUnderlying

writeable!, #writeable?

Constructor Details

#initialize(num, outletgroup) ⇒ Outlet

Returns a new instance of Outlet.



9
10
11
12
# File 'lib/denkovi.rb', line 9

def initialize(num, outletgroup)
  @num = num
  @og = outletgroup
end

Instance Method Details

#read(uncached = false) ⇒ Object



18
19
20
# File 'lib/denkovi.rb', line 18

def read(uncached = false)
  {'ON' => 1.0, 'OFF' => 0.0}[@og.state(@num)]
end

#sensor_typeObject



14
15
16
# File 'lib/denkovi.rb', line 14

def sensor_type
  :onoff
end

#write(value) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/denkovi.rb', line 22

def write(value)
  newstate = {1.0 => 'ON', 0.0 => 'OFF'}[value]
  if newstate
    @og.set_state(@num,newstate)
    value
  end
end