Class: Aurora::Humidistat
- Defined in:
- lib/aurora/humidistat.rb
Instance Attribute Summary collapse
-
#dehumidification_target ⇒ Object
Returns the value of attribute dehumidification_target.
-
#dehumidifier_mode ⇒ Object
Returns the value of attribute dehumidifier_mode.
-
#humidification_target ⇒ Object
Returns the value of attribute humidification_target.
-
#humidifier_mode ⇒ Object
Returns the value of attribute humidifier_mode.
-
#humidifier_running ⇒ Object
(also: #humidifier_running?)
readonly
Returns the value of attribute humidifier_running.
-
#relative_humidity ⇒ Object
readonly
Returns the value of attribute relative_humidity.
Instance Method Summary collapse
- #dehumidifier? ⇒ Boolean
- #dehumidifier_running ⇒ Object (also: #dehumidifier_running?)
- #humidifier? ⇒ Boolean
-
#initialize(abc, has_humidifier, has_dehumidifier) ⇒ Humidistat
constructor
A new instance of Humidistat.
- #refresh(registers) ⇒ Object
- #registers_to_read ⇒ Object
- #set_humidistat_mode(humidifier_mode, dehumidifier_mode) ⇒ Object
- #set_humidistat_targets(humidification_target, dehumidification_target) ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(abc, has_humidifier, has_dehumidifier) ⇒ Humidistat
Returns a new instance of Humidistat.
15 16 17 18 19 |
# File 'lib/aurora/humidistat.rb', line 15 def initialize(abc, has_humidifier, has_dehumidifier) super(abc) @humidifier = has_humidifier @dehumidifier = has_dehumidifier end |
Instance Attribute Details
#dehumidification_target ⇒ Object
Returns the value of attribute dehumidification_target.
7 8 9 |
# File 'lib/aurora/humidistat.rb', line 7 def dehumidification_target @dehumidification_target end |
#dehumidifier_mode ⇒ Object
Returns the value of attribute dehumidifier_mode.
7 8 9 |
# File 'lib/aurora/humidistat.rb', line 7 def dehumidifier_mode @dehumidifier_mode end |
#humidification_target ⇒ Object
Returns the value of attribute humidification_target.
7 8 9 |
# File 'lib/aurora/humidistat.rb', line 7 def humidification_target @humidification_target end |
#humidifier_mode ⇒ Object
Returns the value of attribute humidifier_mode.
7 8 9 |
# File 'lib/aurora/humidistat.rb', line 7 def humidifier_mode @humidifier_mode end |
#humidifier_running ⇒ Object (readonly) Also known as: humidifier_running?
Returns the value of attribute humidifier_running.
7 8 9 |
# File 'lib/aurora/humidistat.rb', line 7 def humidifier_running @humidifier_running end |
#relative_humidity ⇒ Object (readonly)
Returns the value of attribute relative_humidity.
7 8 9 |
# File 'lib/aurora/humidistat.rb', line 7 def relative_humidity @relative_humidity end |
Instance Method Details
#dehumidifier? ⇒ Boolean
25 26 27 |
# File 'lib/aurora/humidistat.rb', line 25 def dehumidifier? @dehumidifier end |
#dehumidifier_running ⇒ Object Also known as: dehumidifier_running?
29 30 31 |
# File 'lib/aurora/humidistat.rb', line 29 def dehumidifier_running dehumidifier? ? @dehumidifier_running : abc.current_mode == :dehumidify end |
#humidifier? ⇒ Boolean
21 22 23 |
# File 'lib/aurora/humidistat.rb', line 21 def humidifier? @humidifier end |
#refresh(registers) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aurora/humidistat.rb', line 44 def refresh(registers) @relative_humidity = registers[741] outputs = registers[30] @humidifier_running = humidifier? && outputs.include?(:accessory) if abc.axb? outputs = registers[1104] @dehumidifer_running = dehumidifier? && outputs.include?(:accessory2) end return unless abc.awl_communicating? base = abc.iz2? ? 31_109 : 12_309 humidifier_settings_register = abc.iz2? ? 21_114 : 12_309 @humidifier_settings = registers[humidifier_settings_register]&.last&.[](2..-1)&.to_i(16) @humidifier_mode = registers[humidifier_settings_register]&.include?(:auto_humidification) ? :auto : :manual @dehumidifier_mode = registers[humidifier_settings_register]&.include?(:auto_dehumidification) ? :auto : :manual @humidification_target = registers[base + 1]&.[](:humidification_target) @dehumidification_target = registers[base + 1]&.[](:dehumidification_target) end |
#registers_to_read ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/aurora/humidistat.rb', line 34 def registers_to_read return [] unless @abc.awl_communicating? result = [741] if humidifier? || dehumidifier? || abc.compressor.is_a?(Compressor::VSDrive) result.concat(abc.iz2? ? [21_114, 31_109..31_110] : [12_309..12_310]) end result end |
#set_humidistat_mode(humidifier_mode, dehumidifier_mode) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/aurora/humidistat.rb', line 75 def set_humidistat_mode(humidifier_mode, dehumidifier_mode) allowed = %i[auto manual] raise ArgumentError unless allowed.include?(humidifier_mode) && allowed.include?(dehumidifier_mode) # start with the prior value of the register, since I'm not sure what # else is stuffed in there raw_value = @humidifier_settings raw_value |= 0x4000 if humidifier_mode == :auto raw_value |= 0x8000 if dehumidifier_mode == :auto holding_registers[abc.iz2? ? 21_114 : 12_309] = raw_value end |
#set_humidistat_targets(humidification_target, dehumidification_target) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/aurora/humidistat.rb', line 95 def set_humidistat_targets(humidification_target, dehumidification_target) raise ArgumentError unless (15..50).cover?(humidification_target) raise ArgumentError unless (35..65).cover?(dehumidification_target) holding_registers[abc.iz2? ? 21_115 : 12_310] = (humidification_target << 8) + dehumidification_target end |