waterfurnace_aurora 0.3.5 → 0.3.9

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: 85309a61ae279d3255db42a0ff3d53a038c1fdcb3c7e02e3febf6b533992a2c3
4
- data.tar.gz: be76ef3d6821fbd8535192fd4a55f770234f1736fb280a7a3736fa6c134a1085
3
+ metadata.gz: 6920a48439c274a9c5f7cec06ebeabf6c97a91018f107d090ce8be793f307f99
4
+ data.tar.gz: 4a7e518fcca1ec7c52d7bd1bee6d294a59b31e9f0d759270a1a2bcd2f8c75270
5
5
  SHA512:
6
- metadata.gz: a45f409c8573e02e7b761c6363abfea445f6e86fe58fab96b5e2ed427564ba791ff83c8817c74d2ff90028eae0c35fb4f090c0a28d3e9c6931aab45e2658c580
7
- data.tar.gz: b5d793acc1dbca113c11205198b6ad6623b29543b5c5cc095ab8f4ddf0d5d9fbcf98fc5ca586e534d516027bc446bec2ee164fd3bb7f36ba6309b63517b13524
6
+ metadata.gz: 504b790c101f15dc79f5985b3fdcab529f746d912aaef0865c59404240f95908ca72a70aa262af4917b7409ac9d5366f24167eddc33ba8ba5786d0213f7b3776
7
+ data.tar.gz: def8a5362616f511f514a0f3e3008302dfa0fa71d9e7ac4bd0d937cd76083ec6118cc8240e100bf5099cd610926dc912c8d4eaf50b4f7cb5149fcd5cdbbc88a8
data/exe/aurora_fetch CHANGED
@@ -3,24 +3,51 @@
3
3
 
4
4
  require "aurora"
5
5
  require "ccutrer-serialport"
6
+ require "logger"
7
+ require "optparse"
6
8
  require "uri"
7
9
 
10
+ debug_modbus = false
11
+
12
+ opts = OptionParser.new do |opts|
13
+ opts.banner = "Usage: aurora_fetch /path/to/serial/port REGISTERS [options]"
14
+
15
+ opts.on("--debug-modbus", "Print actual protocol bytes") { debug_modbus = true }
16
+ opts.on("-h", "--help", "Prints this help") do
17
+ puts opts
18
+ exit
19
+ end
20
+ end
21
+
22
+ opts.parse!
23
+
24
+ unless ARGV.length == 2
25
+ puts opts
26
+ exit 1
27
+ end
28
+
8
29
  uri = URI.parse(ARGV[0])
9
30
 
10
- args = if uri.scheme == "telnet" || uri.scheme == "rfc2217"
31
+ args = case uri.scheme
32
+ when "tcp"
33
+ require "socket"
34
+ [TCPSocket.new(uri.host, uri.port)]
35
+ when "telnet", "rfc2217"
11
36
  require "net/telnet/rfc2217"
12
- [Net::Telnet::RFC2217.new("Host" => uri.host,
13
- "Port" => uri.port || 23,
14
- "baud" => 19_200,
15
- "parity" => Net::Telnet::RFC2217::EVEN)]
37
+ [Net::Telnet::RFC2217.new(uri.host,
38
+ port: uri.port || 23,
39
+ baud: 19_200,
40
+ parity: :even)]
16
41
  else
17
42
  [CCutrer::SerialPort.new(uri.path, baud: 19_200, parity: :even)]
18
43
  end
19
44
 
20
45
  client = ModBus::RTUClient.new(*args)
21
- client.logger = Logger.new($stdout, :debug)
22
- slave = client.with_slave(1)
46
+ client.logger = Logger.new($stdout)
47
+ client.logger.level = debug_modbus ? :debug : :warn
23
48
 
24
- registers = slave.holding_registers[ARGV[1].to_i]
49
+ slave = client.with_slave(1)
50
+ abc = Aurora::ABCClient.new(slave)
51
+ registers = abc.query_registers(ARGV[1])
25
52
 
26
- puts registers.inspect
53
+ puts Aurora.print_registers(registers)
data/exe/aurora_mock CHANGED
@@ -8,12 +8,16 @@ require "yaml"
8
8
 
9
9
  uri = URI.parse(ARGV[0])
10
10
 
11
- args = if uri.scheme == "telnet" || uri.scheme == "rfc2217"
11
+ args = case uri.scheme
12
+ when "tcp"
13
+ require "socket"
14
+ [TCPSocket.new(uri.host, uri.port)]
15
+ when "telnet", "rfc2217"
12
16
  require "net/telnet/rfc2217"
13
- [Net::Telnet::RFC2217.new("Host" => uri.host,
14
- "Port" => uri.port || 23,
15
- "baud" => 19_200,
16
- "parity" => Net::Telnet::RFC2217::EVEN)]
17
+ [Net::Telnet::RFC2217.new(uri.host,
18
+ port: uri.port || 23,
19
+ baud: 19_200,
20
+ parity: :even)]
17
21
  else
18
22
  [CCutrer::SerialPort.new(uri.path, baud: 19_200, parity: :even)]
19
23
  end
data/exe/aurora_monitor CHANGED
@@ -36,12 +36,16 @@ last_registers = {}
36
36
  SENSOR_REGISTERS = [16, 19, 20, 740, 900, 1109, 1105, 1106, 1107, 1108, 1110, 1111, 1114, 1117, 1134, 1147, 1149, 1151,
37
37
  1153, 1165].freeze
38
38
 
39
- args = if uri.scheme == "telnet" || uri.scheme == "rfc2217"
39
+ args = case uri.scheme
40
+ when "tcp"
41
+ require "socket"
42
+ [TCPSocket.new(uri.host, uri.port)]
43
+ when "telnet", "rfc2217"
40
44
  require "net/telnet/rfc2217"
41
- [Net::Telnet::RFC2217.new("Host" => uri.host,
42
- "Port" => uri.port || 23,
43
- "baud" => 19_200,
44
- "parity" => Net::Telnet::RFC2217::EVEN)]
45
+ [Net::Telnet::RFC2217.new(uri.host,
46
+ port: uri.port || 23,
47
+ baud: 19_200,
48
+ parity: :even)]
45
49
  else
46
50
  [CCutrer::SerialPort.new(uri.path, baud: 19_200, parity: :even)]
47
51
  end
@@ -49,7 +53,7 @@ args = if uri.scheme == "telnet" || uri.scheme == "rfc2217"
49
53
  server = ModBus::RTUServer.new(*args)
50
54
  server.promiscuous = true
51
55
  server.logger = Logger.new($stdout)
52
- server.logger.level = :debug if debug_modbus
56
+ server.logger.level = debug_modbus ? :debug : :warn
53
57
 
54
58
  diff_and_print = lambda do |registers|
55
59
  registers = registers.slice(*(registers.keys - SENSOR_REGISTERS)) if ignore_sensors
@@ -10,12 +10,16 @@ require "aurora/core_ext/string"
10
10
  uri = URI.parse(ARGV[0])
11
11
  mqtt_uri = ARGV[1]
12
12
 
13
- args = if uri.scheme == "telnet" || uri.scheme == "rfc2217"
13
+ args = case uri.scheme
14
+ when "tcp"
15
+ require "socket"
16
+ [TCPSocket.new(uri.host, uri.port)]
17
+ when "telnet", "rfc2217"
14
18
  require "net/telnet/rfc2217"
15
- [Net::Telnet::RFC2217.new("Host" => uri.host,
16
- "Port" => uri.port || 23,
17
- "baud" => 19_200,
18
- "parity" => Net::Telnet::RFC2217::EVEN)]
19
+ [Net::Telnet::RFC2217.new(uri.host,
20
+ port: uri.port || 23,
21
+ baud: 19_200,
22
+ parity: :even)]
19
23
  else
20
24
  [CCutrer::SerialPort.new(uri.path, baud: 19_200, parity: :even)]
21
25
  end
@@ -33,21 +37,7 @@ class MQTTBridge
33
37
  @mutex.synchronize do
34
38
  case topic
35
39
  when /\$modbus$/
36
- query = value.split(",").map do |addr|
37
- case addr
38
- when "known"
39
- Aurora::REGISTER_NAMES.keys
40
- when /^(\d+)(?:\.\.|-)(\d+)$/
41
- $1.to_i..$2.to_i
42
- else
43
- addr.to_i
44
- end
45
- end
46
- queries = Aurora.normalize_ranges(query)
47
- registers = {}
48
- queries.each do |subquery|
49
- registers.merge!(@abc.modbus_slave.read_multiple_holding_registers(*subquery))
50
- end
40
+ registers = @abc.query_registers(value)
51
41
  Aurora.print_registers(registers) do |register, v|
52
42
  @homie.mqtt.publish("#{@homie.topic}/$modbus/#{register}", v, retain: false, qos: 1)
53
43
  end
@@ -42,6 +42,25 @@ module Aurora
42
42
  end
43
43
  end
44
44
 
45
+ def query_registers(query)
46
+ ranges = query.split(",").map do |addr|
47
+ case addr
48
+ when "known"
49
+ Aurora::REGISTER_NAMES.keys
50
+ when /^(\d+)(?:\.\.|-)(\d+)$/
51
+ $1.to_i..$2.to_i
52
+ else
53
+ addr.to_i
54
+ end
55
+ end
56
+ queries = Aurora.normalize_ranges(ranges)
57
+ registers = {}
58
+ queries.each do |subquery|
59
+ registers.merge!(@modbus_slave.read_multiple_holding_registers(*subquery))
60
+ end
61
+ registers
62
+ end
63
+
45
64
  def refresh
46
65
  registers_to_read = [19..20, 30, 340, 344, 347, 740..741, 900, 1110..1111, 1114, 1117, 1147..1153, 1165, 3027,
47
66
  31_003]
@@ -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
@@ -594,7 +594,10 @@ module Aurora
594
594
  12_619 => "Heating Setpoint (write)",
595
595
  12_620 => "Cooling Setpoint (write)",
596
596
  12_621 => "Fan Mode (write)",
597
+ 3000 => "Compressor Speed?",
598
+ 3001 => "Compressor Speed?",
597
599
  3027 => "Compressor Speed",
600
+ 3904 => "Leaving Air Temperature?",
598
601
  31_003 => "Outdoor Temp",
599
602
  31_005 => "IZ2 Demand",
600
603
  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.5"
4
+ VERSION = "0.3.9"
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.5
4
+ version: 0.3.9
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-26 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
@@ -44,14 +44,20 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.4
47
+ version: '1.0'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.0.1
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
- version: 0.0.4
57
+ version: '1.0'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.0.1
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rmodbus-ccutrer
57
63
  requirement: !ruby/object:Gem::Requirement