Class: Aurora::IZ2Zone

Inherits:
Thermostat show all
Defined in:
lib/aurora/iz2_zone.rb

Instance Attribute Summary collapse

Attributes inherited from Thermostat

#ambient_temperature, #cooling_target_temperature, #current_fan_mode, #current_mode, #fan_intermittent_off, #fan_intermittent_on, #heating_target_temperature, #target_fan_mode, #target_mode

Instance Method Summary collapse

Methods inherited from Component

#inspect

Constructor Details

#initialize(abc, zone_number) ⇒ IZ2Zone

Returns a new instance of IZ2Zone.



12
13
14
15
# File 'lib/aurora/iz2_zone.rb', line 12

def initialize(abc, zone_number)
  super(abc)
  @zone_number = zone_number
end

Instance Attribute Details

#normalized_sizeObject (readonly)

Returns the value of attribute normalized_size.



7
8
9
# File 'lib/aurora/iz2_zone.rb', line 7

def normalized_size
  @normalized_size
end

#priorityObject (readonly)

Returns the value of attribute priority.



7
8
9
# File 'lib/aurora/iz2_zone.rb', line 7

def priority
  @priority
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/aurora/iz2_zone.rb', line 7

def size
  @size
end

#zone_numberObject (readonly)

Returns the value of attribute zone_number.



7
8
9
# File 'lib/aurora/iz2_zone.rb', line 7

def zone_number
  @zone_number
end

Instance Method Details

#cooling_target_temperature=(value) ⇒ Object



76
77
78
79
80
81
# File 'lib/aurora/iz2_zone.rb', line 76

def cooling_target_temperature=(value)
  return unless value >= 54 && value <= 99

  raw_value = (value * 10).to_i
  holding_registers[21_204 + ((zone_number - 1) * 9)] = raw_value
end

#fan_intermittent_off=(value) ⇒ Object



63
64
65
66
67
# File 'lib/aurora/iz2_zone.rb', line 63

def fan_intermittent_off=(value)
  return unless value >= 0 && value <= 40 && (value % 5).zero?

  holding_registers[21_207 + ((zone_number - 1) * 9)] = value
end

#fan_intermittent_on=(value) ⇒ Object



57
58
59
60
61
# File 'lib/aurora/iz2_zone.rb', line 57

def fan_intermittent_on=(value)
  return unless value >= 0 && value <= 25 && (value % 5).zero?

  holding_registers[21_206 + ((zone_number - 1) * 9)] = value
end

#heating_target_temperature=(value) ⇒ Object



69
70
71
72
73
74
# File 'lib/aurora/iz2_zone.rb', line 69

def heating_target_temperature=(value)
  return unless value >= 40 && value <= 90

  raw_value = (value * 10).to_i
  holding_registers[21_203 + ((zone_number - 1) * 9)] = raw_value
end

#refresh(registers) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/aurora/iz2_zone.rb', line 24

def refresh(registers)
  @ambient_temperature = registers[31_007 + ((zone_number - 1) * 3)]

  config1 = registers[31_008 + ((zone_number - 1) * 3)]
  config2 = registers[31_009 + ((zone_number - 1) * 3)]
  config3 = registers[31_200 + ((zone_number - 1) * 3)]

  @target_fan_mode = config1[:fan]
  @fan_intermittent_on = config1[:on_time]
  @fan_intermittent_off = config1[:off_time]
  @cooling_target_temperature = config1[:cooling_target_temperature]
  @heating_target_temperature = config2[:heating_target_temperature]
  @target_mode = config2[:mode]
  @current_mode = config2[:call]
  @current_fan_mode = config2[:damper] == :open

  @priority = config3[:zone_priority]
  @size = config3[:zone_size]
  @normalized_size = config3[:normalized_size]
end

#registers_to_readObject



17
18
19
20
21
22
# File 'lib/aurora/iz2_zone.rb', line 17

def registers_to_read
  base1 = 21_203 + ((zone_number - 1) * 9)
  base2 = 31_007 + ((zone_number - 1) * 3)
  base3 = 31_200 + ((zone_number - 1) * 3)
  [base1..(base1 + 1), base2..(base2 + 2), base3]
end

#target_fan_mode=(value) ⇒ Object



51
52
53
54
55
# File 'lib/aurora/iz2_zone.rb', line 51

def target_fan_mode=(value)
  return unless (raw_value = Aurora::FAN_MODE.invert[value])

  holding_registers[21_205 + ((zone_number - 1) * 9)] = raw_value
end

#target_mode=(value) ⇒ Object



45
46
47
48
49
# File 'lib/aurora/iz2_zone.rb', line 45

def target_mode=(value)
  return unless (raw_value = Aurora::HEATING_MODE.invert[value])

  holding_registers[21_202 + ((zone_number - 1) * 9)] = raw_value
end