Class: Fritzbox::Smarthome::Switch
- Defined in:
- lib/fritzbox/smarthome/switch.rb
Instance Attribute Summary collapse
-
#powermeter_energy ⇒ Object
Returns the value of attribute powermeter_energy.
-
#powermeter_power ⇒ Object
Returns the value of attribute powermeter_power.
-
#powermeter_voltage ⇒ Object
Returns the value of attribute powermeter_voltage.
-
#simpleonoff_state ⇒ Object
Returns the value of attribute simpleonoff_state.
-
#switch_devicelock ⇒ Object
Returns the value of attribute switch_devicelock.
-
#switch_lock ⇒ Object
Returns the value of attribute switch_lock.
-
#switch_mode ⇒ Object
Returns the value of attribute switch_mode.
-
#switch_state ⇒ Object
Returns the value of attribute switch_state.
-
#temperature_celsius ⇒ Object
Returns the value of attribute temperature_celsius.
-
#temperature_offset ⇒ Object
Returns the value of attribute temperature_offset.
Attributes inherited from Actor
#ain, #group_members, #id, #manufacturer, #name, #present, #type
Class Method Summary collapse
Methods inherited from Actor
Methods inherited from Resource
Instance Attribute Details
#powermeter_energy ⇒ Object
Returns the value of attribute powermeter_energy.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def powermeter_energy @powermeter_energy end |
#powermeter_power ⇒ Object
Returns the value of attribute powermeter_power.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def powermeter_power @powermeter_power end |
#powermeter_voltage ⇒ Object
Returns the value of attribute powermeter_voltage.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def powermeter_voltage @powermeter_voltage end |
#simpleonoff_state ⇒ Object
Returns the value of attribute simpleonoff_state.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def simpleonoff_state @simpleonoff_state end |
#switch_devicelock ⇒ Object
Returns the value of attribute switch_devicelock.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def switch_devicelock @switch_devicelock end |
#switch_lock ⇒ Object
Returns the value of attribute switch_lock.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def switch_lock @switch_lock end |
#switch_mode ⇒ Object
Returns the value of attribute switch_mode.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def switch_mode @switch_mode end |
#switch_state ⇒ Object
Returns the value of attribute switch_state.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def switch_state @switch_state end |
#temperature_celsius ⇒ Object
Returns the value of attribute temperature_celsius.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def temperature_celsius @temperature_celsius end |
#temperature_offset ⇒ Object
Returns the value of attribute temperature_offset.
5 6 7 |
# File 'lib/fritzbox/smarthome/switch.rb', line 5 def temperature_offset @temperature_offset end |
Class Method Details
.match?(data) ⇒ Boolean
18 19 20 |
# File 'lib/fritzbox/smarthome/switch.rb', line 18 def match?(data) data.key?('switch') end |
.new_from_api(data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fritzbox/smarthome/switch.rb', line 22 def new_from_api(data) instance = super instance.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, simpleonoff_state: data.dig('simpleonoff', 'state').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 ) instance end |