21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/sensibo/models/device.rb', line 21
def save
requires :identity
temp = if self.temperature_unit == self.native_temperature_unit
self.target_temperature
elsif self.temperature_unit == "F"
c_to_f(f_to_c(self.target_temperature))
elsif self.temperature_unit == "C"
f_to_c(c_to_f(self.target_temperature))
end
body = {
"acState" => {
"fanLevel" => self.fan_level,
"mode" => self.mode,
"on" => self.power_on,
"swing" => self.swing,
"targetTemperature" => temp,
"temperatureUnit" => self.temperature_unit,
}
}
body = cistern.set_device_state(self.id, body)["result"]
raise RuntimeError.new("Save Failed") unless body["status"] == "Success"
end
|