Class: Fritzbox::Smarthome::Switch

Inherits:
Actor show all
Includes:
Properties::SimpleOnOff
Defined in:
lib/fritzbox/smarthome/switch.rb

Constant Summary

Constants inherited from Actor

Actor::ResourceNotFound

Instance Attribute Summary collapse

Attributes inherited from Actor

#ain, #group_members, #id, #manufacturer, #name, #present, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Properties::SimpleOnOff

#active?, #toggle!

Methods inherited from Actor

all, find_by!, new_from_api, #reload

Methods inherited from Resource

get, parse

Instance Attribute Details

#powermeter_energyObject

Returns the value of attribute powermeter_energy.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def powermeter_energy
  @powermeter_energy
end

#powermeter_powerObject

Returns the value of attribute powermeter_power.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def powermeter_power
  @powermeter_power
end

#powermeter_voltageObject

Returns the value of attribute powermeter_voltage.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def powermeter_voltage
  @powermeter_voltage
end

#switch_devicelockObject

Returns the value of attribute switch_devicelock.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def switch_devicelock
  @switch_devicelock
end

#switch_lockObject

Returns the value of attribute switch_lock.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def switch_lock
  @switch_lock
end

#switch_modeObject

Returns the value of attribute switch_mode.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def switch_mode
  @switch_mode
end

#switch_stateObject

Returns the value of attribute switch_state.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def switch_state
  @switch_state
end

#temperature_celsiusObject

Returns the value of attribute temperature_celsius.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def temperature_celsius
  @temperature_celsius
end

#temperature_offsetObject

Returns the value of attribute temperature_offset.



7
8
9
# File 'lib/fritzbox/smarthome/switch.rb', line 7

def temperature_offset
  @temperature_offset
end

Class Method Details

.match?(data) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fritzbox/smarthome/switch.rb', line 19

def match?(data)
  data.key?('switch')
end

Instance Method Details

#assign_from_api(data) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fritzbox/smarthome/switch.rb', line 24

def assign_from_api(data)
  super(data)

  assign_attributes(
    switch_state:        data.dig('switch', 'state').to_i,
    switch_mode:         data.dig('switch', 'mode').to_s,
    switch_lock:         data.dig('switch', 'lock').to_i,
    switch_devicelock:   data.dig('switch', 'devicelock').to_i,
    powermeter_voltage:  data.dig('powermeter', 'voltage').to_i,
    powermeter_power:    data.dig('powermeter', 'power').to_i,
    powermeter_energy:   data.dig('powermeter', 'energy').to_i,
    temperature_celsius: data.dig('temperature', 'celsius').to_i,
    temperature_offset:  data.dig('temperature', 'offset').to_i
  )
end