Class: Fritzbox::Smarthome::Heater
- Inherits:
-
Actor
show all
- Defined in:
- lib/fritzbox/smarthome/heater.rb
Constant Summary
Constants inherited
from Actor
Actor::ResourceNotFound
Constants inherited
from Resource
Resource::AuthenticationError
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Actor
all, find_by!, new_from_api, #reload
Methods inherited from Resource
get, parse
Class Method Details
.match?(data) ⇒ Boolean
12
13
14
|
# File 'lib/fritzbox/smarthome/heater.rb', line 12
def match?(data)
data.key?('hkr')
end
|
Instance Method Details
#assign_from_api(data) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/fritzbox/smarthome/heater.rb', line 17
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
30
31
32
33
34
35
36
|
# File 'lib/fritzbox/smarthome/heater.rb', line 30
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
|