Class: Fritzbox::Smarthome::Heater
- Defined in:
- lib/fritzbox/smarthome/heater.rb
Constant Summary
Constants inherited from Actor
Constants inherited from Resource
Instance Attribute Summary collapse
-
#battery ⇒ Object
Returns the value of attribute battery.
-
#batterylow ⇒ Object
Returns the value of attribute batterylow.
-
#hkr_next_change_period ⇒ Object
Returns the value of attribute hkr_next_change_period.
-
#hkr_next_change_temp ⇒ Object
Returns the value of attribute hkr_next_change_temp.
-
#hkr_temp_is ⇒ Object
Returns the value of attribute hkr_temp_is.
-
#hkr_temp_set ⇒ Object
Returns the value of attribute hkr_temp_set.
Attributes inherited from Actor
#ain, #group_members, #id, #manufacturer, #name, #present, #type
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Actor
all, find_by!, new_from_api, #reload
Methods inherited from Resource
Instance Attribute Details
#battery ⇒ Object
Returns the value of attribute battery.
5 6 7 |
# File 'lib/fritzbox/smarthome/heater.rb', line 5 def battery @battery end |
#batterylow ⇒ Object
Returns the value of attribute batterylow.
5 6 7 |
# File 'lib/fritzbox/smarthome/heater.rb', line 5 def batterylow @batterylow end |
#hkr_next_change_period ⇒ Object
Returns the value of attribute hkr_next_change_period.
5 6 7 |
# File 'lib/fritzbox/smarthome/heater.rb', line 5 def hkr_next_change_period @hkr_next_change_period end |
#hkr_next_change_temp ⇒ Object
Returns the value of attribute hkr_next_change_temp.
5 6 7 |
# File 'lib/fritzbox/smarthome/heater.rb', line 5 def hkr_next_change_temp @hkr_next_change_temp end |
#hkr_temp_is ⇒ Object
Returns the value of attribute hkr_temp_is.
5 6 7 |
# File 'lib/fritzbox/smarthome/heater.rb', line 5 def hkr_temp_is @hkr_temp_is end |
#hkr_temp_set ⇒ Object
Returns the value of attribute hkr_temp_set.
5 6 7 |
# File 'lib/fritzbox/smarthome/heater.rb', line 5 def hkr_temp_set @hkr_temp_set end |
Class Method Details
.match?(data) ⇒ Boolean
14 15 16 |
# File 'lib/fritzbox/smarthome/heater.rb', line 14 def match?(data) data.key?('hkr') end |
Instance Method Details
#assign_from_api(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fritzbox/smarthome/heater.rb', line 19 def assign_from_api(data) super(data) assign_attributes( battery: data.dig('battery').to_i, batterylow: data.dig('batterylow').to_i, hkr_temp_is: data.dig('hkr', 'tist').to_i * 0.5, hkr_temp_set: data.dig('hkr', 'tsoll').to_i * 0.5, hkr_next_change_period: Time.at(data.dig('hkr', 'nextchange', 'endperiod').to_i), hkr_next_change_temp: data.dig('hkr', 'nextchange', 'tchange').to_i * 0.5 ) end |
#update_hkr_temp_set(value) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/fritzbox/smarthome/heater.rb', line 32 def update_hkr_temp_set(value) raise ArgumentError unless value.is_a? BigDecimal value = (value / 0.5).to_i response = self.class.get(command: 'sethkrtsoll', ain: ain, param: value) raise 'Could not set temperature' unless response.body == "#{value}\n" true end |