waterfurnace_aurora 0.3.6 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e288948a5037bccfc008daaac58c7c604f2531fab6c6554c5a93c47ab8846f2
4
- data.tar.gz: 7dde859984d21e24f3915307de12a940e17159715ae2e1047fa80c9955ed5cbf
3
+ metadata.gz: 9043266cc8a0382960f9ee29954fa9da2c33f8507c3d0075c58d9651618fa128
4
+ data.tar.gz: 40520db833f13a4caea708589a334b21198ed551376ee70aff666c875257ea03
5
5
  SHA512:
6
- metadata.gz: ac5d6fb9dd6812cd71903eab37f7a32c89ad5f8790956e7adb4782216d59247873be7c603e362caab4679ca489f496579564bcc683d739caeb69ef86cab103b6
7
- data.tar.gz: 826ff34760c126c99e19c8be8a5a929938def25d5078ff7c2141c70136a1120fcc99bf997160b2002187f17bb5009a4ac2b67c433855f90c0f7a84c248ba95f1
6
+ metadata.gz: b8db6bf0c4f1e19270792fd43d16e06dcb3a1ab357c8553d6cc39bb820f546ff3782472a3c8f7cde7d2323686d7712c2f2699d53b8cd984344bda02982a979bc
7
+ data.tar.gz: 70d7fa1a21e3c3003f24f1cbe8e5909ceb216002e98d08e3262e9f56a3c2636af775a7e47b2422bbbe7511d8cf5ae390436b0d809f28a4e34f6c21ed609327a1
data/exe/aurora_fetch CHANGED
@@ -3,7 +3,30 @@
3
3
 
4
4
  require "aurora"
5
5
  require "ccutrer-serialport"
6
+ require "logger"
7
+ require "optparse"
6
8
  require "uri"
9
+ require "yaml"
10
+
11
+ debug_modbus = yaml = false
12
+
13
+ options = OptionParser.new do |opts|
14
+ opts.banner = "Usage: aurora_fetch /path/to/serial/port REGISTERS [options]"
15
+
16
+ opts.on("--debug-modbus", "Print actual protocol bytes") { debug_modbus = true }
17
+ opts.on("-y", "--yaml", "Output raw values as YAML") { yaml = true }
18
+ opts.on("-h", "--help", "Prints this help") do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+
24
+ options.parse!
25
+
26
+ unless ARGV.length == 2
27
+ puts options
28
+ exit 1
29
+ end
7
30
 
8
31
  uri = URI.parse(ARGV[0])
9
32
 
@@ -22,9 +45,15 @@ args = case uri.scheme
22
45
  end
23
46
 
24
47
  client = ModBus::RTUClient.new(*args)
25
- client.logger = Logger.new($stdout, :debug)
26
- slave = client.with_slave(1)
48
+ client.logger = Logger.new($stdout)
49
+ client.logger.level = debug_modbus ? :debug : :warn
27
50
 
28
- registers = slave.holding_registers[ARGV[1].to_i]
51
+ slave = client.with_slave(1)
52
+ abc = Aurora::ABCClient.new(slave)
53
+ registers = abc.query_registers(ARGV[1])
29
54
 
30
- puts registers.inspect
55
+ if yaml
56
+ puts YAML.dump(registers)
57
+ else
58
+ puts Aurora.print_registers(registers)
59
+ end
@@ -37,21 +37,7 @@ class MQTTBridge
37
37
  @mutex.synchronize do
38
38
  case topic
39
39
  when /\$modbus$/
40
- query = value.split(",").map do |addr|
41
- case addr
42
- when "known"
43
- Aurora::REGISTER_NAMES.keys
44
- when /^(\d+)(?:\.\.|-)(\d+)$/
45
- $1.to_i..$2.to_i
46
- else
47
- addr.to_i
48
- end
49
- end
50
- queries = Aurora.normalize_ranges(query)
51
- registers = {}
52
- queries.each do |subquery|
53
- registers.merge!(@abc.modbus_slave.read_multiple_holding_registers(*subquery))
54
- end
40
+ registers = @abc.query_registers(value)
55
41
  Aurora.print_registers(registers) do |register, v|
56
42
  @homie.mqtt.publish("#{@homie.topic}/$modbus/#{register}", v, retain: false, qos: 1)
57
43
  end
@@ -85,6 +71,10 @@ class MQTTBridge
85
71
  property.value = @abc.public_send(property.id.tr("-", "_"))
86
72
  end
87
73
 
74
+ @abc.faults.each_with_index do |fault_count, i|
75
+ @faults["e#{i + 1}"].value = fault_count
76
+ end
77
+
88
78
  @abc.zones.each_with_index do |z, idx|
89
79
  homie_zone = @homie["zone#{idx + 1}"]
90
80
  homie_zone.each do |property|
@@ -139,6 +129,13 @@ class MQTTBridge
139
129
  end
140
130
  end
141
131
 
132
+ @faults = @homie.node("faults", "Fault History", "ABC") do |node|
133
+ @abc.faults.each_with_index do |count, i|
134
+ name = Aurora::FAULTS[i + 1]
135
+ node.property("e#{i + 1}", name || "E#{i + 1}", :integer, count)
136
+ end
137
+ end
138
+
142
139
  @abc.zones.each_with_index do |zone, i|
143
140
  type = zone.is_a?(Aurora::IZ2Zone) ? "IntelliZone 2 Zone" : "Thermostat"
144
141
  @homie.node("zone#{i + 1}", "Zone #{i + 1}", type) do |node|
@@ -5,6 +5,7 @@ module Aurora
5
5
  attr_reader :modbus_slave,
6
6
  :serial_number,
7
7
  :zones,
8
+ :faults,
8
9
  :current_mode,
9
10
  :fan_speed,
10
11
  :entering_air_temperature,
@@ -40,11 +41,33 @@ module Aurora
40
41
  iz2_zone_count = @modbus_slave.holding_registers[483]
41
42
  (0...iz2_zone_count).map { |i| IZ2Zone.new(self, i + 1) }
42
43
  end
44
+ @faults = []
45
+ end
46
+
47
+ def query_registers(query)
48
+ ranges = query.split(",").map do |addr|
49
+ case addr
50
+ when "known"
51
+ Aurora::REGISTER_NAMES.keys
52
+ when "valid"
53
+ break Aurora::REGISTER_RANGES
54
+ when /^(\d+)(?:\.\.|-)(\d+)$/
55
+ $1.to_i..$2.to_i
56
+ else
57
+ addr.to_i
58
+ end
59
+ end
60
+ queries = Aurora.normalize_ranges(ranges)
61
+ registers = {}
62
+ queries.each do |subquery|
63
+ registers.merge!(@modbus_slave.read_multiple_holding_registers(*subquery))
64
+ end
65
+ registers
43
66
  end
44
67
 
45
68
  def refresh
46
- registers_to_read = [19..20, 30, 340, 344, 347, 740..741, 900, 1110..1111, 1114, 1117, 1147..1153, 1165, 3027,
47
- 31_003]
69
+ registers_to_read = [19..20, 30, 340, 344, 347, 740..741, 900, 1110..1111, 1114, 1117, 1147..1153, 1165,
70
+ 3027, 31_003]
48
71
  if zones.first.is_a?(IZ2Zone)
49
72
  zones.each_with_index do |_z, i|
50
73
  base1 = 21_203 + i * 9
@@ -58,6 +81,8 @@ module Aurora
58
81
  registers_to_read << (745..747)
59
82
  end
60
83
 
84
+ @faults = @modbus_slave.holding_registers[601..699]
85
+
61
86
  registers = @modbus_slave.holding_registers[*registers_to_read]
62
87
  Aurora.transform_registers(registers)
63
88
 
@@ -49,7 +49,8 @@ module Aurora
49
49
  when 0x80..0xff
50
50
  msg += read(io, 3)
51
51
  else
52
- raise ModBus::Errors::IllegalFunction, "Illegal function: #{function_code}"
52
+ log "Rx (#{msg.size} bytes): " + logging_bytes(msg)
53
+ raise ::ModBus::Errors::IllegalFunction, "Illegal function: #{function_code}"
53
54
  end
54
55
  msg
55
56
  end
@@ -3,6 +3,11 @@
3
3
  module Aurora
4
4
  module_function
5
5
 
6
+ # take an array of ranges, and breaks it up into queryable chunks
7
+ # the ABC limits to 100 registers per read operation
8
+ # there also seem to be issues that some ranges can't be read at
9
+ # the same time as other ranges. possibly correspond to different
10
+ # components?
6
11
  def normalize_ranges(ranges)
7
12
  registers = ranges.map { |r| Array(r) }.flatten.sort.uniq
8
13
  result = []
@@ -11,7 +16,10 @@ module Aurora
11
16
  count = 0
12
17
  registers.each_with_index do |r, i|
13
18
  run_start ||= r
14
- next unless i + 1 == registers.length || r + 1 != registers[i + 1]
19
+ next unless i + 1 == registers.length ||
20
+ r + 1 != registers[i + 1] ||
21
+ (r - run_start) == 100 ||
22
+ REGISTER_BREAKPOINTS.include?(r + 1)
15
23
 
16
24
  if r == run_start
17
25
  result << r
@@ -23,7 +31,7 @@ module Aurora
23
31
  else
24
32
  range = run_start..r
25
33
  if count + range.count > 100
26
- totals << result
34
+ totals << result unless result.empty?
27
35
  result = []
28
36
  count = 0
29
37
  end
@@ -390,7 +398,11 @@ module Aurora
390
398
  end
391
399
 
392
400
  def faults(range)
393
- range.map { |i| [i, "E#{i % 100}"] }.to_h
401
+ range.map do |i|
402
+ name = FAULTS[i % 100]
403
+ name = " (#{name})" if name
404
+ [i, "E#{i % 100}#{name}"]
405
+ end.to_h
394
406
  end
395
407
 
396
408
  def zone_registers
@@ -494,6 +506,12 @@ module Aurora
494
506
  61_000..61_009
495
507
  ].freeze
496
508
 
509
+ # see normalize_ranges
510
+ REGISTER_BREAKPOINTS = [
511
+ 12_100,
512
+ 12_500
513
+ ].freeze
514
+
497
515
  REGISTER_NAMES = {
498
516
  1 => "Random Start Delay",
499
517
  2 => "ABC Program Version",
@@ -594,7 +612,10 @@ module Aurora
594
612
  12_619 => "Heating Setpoint (write)",
595
613
  12_620 => "Cooling Setpoint (write)",
596
614
  12_621 => "Fan Mode (write)",
615
+ 3000 => "Compressor Speed?",
616
+ 3001 => "Compressor Speed?",
597
617
  3027 => "Compressor Speed",
618
+ 3904 => "Leaving Air Temperature?",
598
619
  31_003 => "Outdoor Temp",
599
620
  31_005 => "IZ2 Demand",
600
621
  31_109 => "Humidifier Mode", # write to 21114
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aurora
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.10"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterfurnace_aurora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-28 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ccutrer-serialport