Class: AtreaControl::Duplex::Unit
- Inherits:
-
Object
- Object
- AtreaControl::Duplex::Unit
- Includes:
- Logger
- Defined in:
- lib/atrea_control/duplex/unit.rb
Overview
Communication with RD5 unit (read/write)
Instance Attribute Summary collapse
-
#current_mode ⇒ Object
readonly
Returns the value of attribute current_mode.
-
#current_power ⇒ Object
readonly
Returns the value of attribute current_power.
-
#input_temperature ⇒ Object
readonly
Returns the value of attribute input_temperature.
-
#outdoor_temperature ⇒ Object
readonly
Returns the value of attribute outdoor_temperature.
-
#preheat_temperature ⇒ Object
readonly
Returns the value of attribute preheat_temperature.
-
#preheating ⇒ Boolean
readonly
Preheating air is ON ?.
- #timestamp ⇒ Object
- #user_ctrl ⇒ UserCtrl readonly
-
#valid_for ⇒ DateTime
readonly
Store time of last update.
Instance Method Summary collapse
- #as_json(_options = nil) ⇒ Object
-
#initialize(user_id:, unit_id:, sid:, user_ctrl: nil) ⇒ Unit
constructor
A new instance of Unit.
- #mode ⇒ Object
- #mode=(value) ⇒ Object
- #name ⇒ Object
-
#params ⇒ Object
Additional “parameters” for each sensors.
- #parsed ⇒ Object
- #power ⇒ Object
- #power=(value) ⇒ Object
- #preheating? ⇒ Boolean
- #to_json ⇒ Object
- #values ⇒ Object
Methods included from Logger
Constructor Details
#initialize(user_id:, unit_id:, sid:, user_ctrl: nil) ⇒ Unit
Returns a new instance of Unit.
23 24 25 26 27 28 |
# File 'lib/atrea_control/duplex/unit.rb', line 23 def initialize(user_id:, unit_id:, sid:, user_ctrl: nil) @user_id = user_id @unit_id = unit_id @sid = sid @user_ctrl = user_ctrl || UserCtrl.new(user_id: user_id, unit_id: unit_id, sid: sid) end |
Instance Attribute Details
#current_mode ⇒ Object (readonly)
Returns the value of attribute current_mode.
9 10 11 |
# File 'lib/atrea_control/duplex/unit.rb', line 9 def current_mode @current_mode end |
#current_power ⇒ Object (readonly)
Returns the value of attribute current_power.
9 10 11 |
# File 'lib/atrea_control/duplex/unit.rb', line 9 def current_power @current_power end |
#input_temperature ⇒ Object (readonly)
Returns the value of attribute input_temperature.
9 10 11 |
# File 'lib/atrea_control/duplex/unit.rb', line 9 def input_temperature @input_temperature end |
#outdoor_temperature ⇒ Object (readonly)
Returns the value of attribute outdoor_temperature.
9 10 11 |
# File 'lib/atrea_control/duplex/unit.rb', line 9 def outdoor_temperature @outdoor_temperature end |
#preheat_temperature ⇒ Object (readonly)
Returns the value of attribute preheat_temperature.
9 10 11 |
# File 'lib/atrea_control/duplex/unit.rb', line 9 def preheat_temperature @preheat_temperature end |
#preheating ⇒ Boolean (readonly)
Returns preheating air is ON ?.
11 12 13 |
# File 'lib/atrea_control/duplex/unit.rb', line 11 def preheating @preheating end |
#timestamp ⇒ Object
42 43 44 |
# File 'lib/atrea_control/duplex/unit.rb', line 42 def @timestamp ||= values[:timestamp] end |
#user_ctrl ⇒ UserCtrl (readonly)
15 16 17 |
# File 'lib/atrea_control/duplex/unit.rb', line 15 def user_ctrl @user_ctrl end |
#valid_for ⇒ DateTime (readonly)
Returns store time of last update.
13 14 15 |
# File 'lib/atrea_control/duplex/unit.rb', line 13 def valid_for @valid_for end |
Instance Method Details
#as_json(_options = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/atrea_control/duplex/unit.rb', line 75 def as_json( = nil) { current_mode: current_mode, current_power: current_power, outdoor_temperature: outdoor_temperature, preheat_temperature: preheat_temperature, input_temperature: input_temperature, preheating: preheating, valid_for: valid_for, timestamp: , } end |
#mode ⇒ Object
34 35 36 |
# File 'lib/atrea_control/duplex/unit.rb', line 34 def mode current_mode || values[:current_mode] end |
#mode=(value) ⇒ Object
51 52 53 54 55 |
# File 'lib/atrea_control/duplex/unit.rb', line 51 def mode=(value) v = [parser.input(@user_ctrl.sensors["mode_input"], value.to_s)] v << parser.input(@user_ctrl.sensors["mode_switch"], "2") write(*v) end |
#name ⇒ Object
30 31 32 |
# File 'lib/atrea_control/duplex/unit.rb', line 30 def name @user_ctrl.name end |
#params ⇒ Object
its changed in time ?
Additional “parameters” for each sensors
94 95 96 97 |
# File 'lib/atrea_control/duplex/unit.rb', line 94 def params response = request.call(_t: "user/params.xml") Nokogiri::XML response.body end |
#parsed ⇒ Object
64 65 66 |
# File 'lib/atrea_control/duplex/unit.rb', line 64 def parsed @parsed ||= parser.values(read.body) end |
#power ⇒ Object
38 39 40 |
# File 'lib/atrea_control/duplex/unit.rb', line 38 def power current_power || values[:current_power] end |
#power=(value) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/atrea_control/duplex/unit.rb', line 57 def power=(value) v = [parser.input(@user_ctrl.sensors["power_input"], value.to_s)] # overtake schedule control v << "H1070000002" if value.to_i.positive? write(*v) end |
#preheating? ⇒ Boolean
46 47 48 |
# File 'lib/atrea_control/duplex/unit.rb', line 46 def preheating? preheating || values[:preheating] end |
#to_json ⇒ Object
88 89 90 |
# File 'lib/atrea_control/duplex/unit.rb', line 88 def to_json(*) values.to_json(*) end |
#values ⇒ Object
68 69 70 71 72 73 |
# File 'lib/atrea_control/duplex/unit.rb', line 68 def values parsed.each do |name, value| instance_variable_set :"@#{name}", value end as_json end |