balboa_worldwide_app 1.1.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e24d4fa8787d36a34d66af9993561f237ecfdf7876e121176870ba93fdd4f67
4
- data.tar.gz: f223828f21309f8742616ab27ee925ddc02eab02304220418a015f25b79802a2
3
+ metadata.gz: 6c8aedb1449973af5ee03ee3927e31e6c5edaa76305ff556ab48eaccc94fc7bf
4
+ data.tar.gz: e43450ff21fe2bfabf8514642b7ce98576a32b60aa3b06a8364c5e8fd8d3ed1a
5
5
  SHA512:
6
- metadata.gz: 2c12165571d6d619af2019fa30d85bee8af5d6758ffd9829363614b4ddab16993706dde33e91b0d5bc76578734a053f12fdad73290018317ec618ef04a6e6beb
7
- data.tar.gz: 8256ecee88d74681ed4b1f25d1b5d75b7f9d20ff3681b973f8ef9f1d80de08ca63c7c622cc60d0ec3394c2323e5013e8a5b073d23dce80dec08c25f7fb4c25f4
6
+ metadata.gz: af663ca63be3bd5f2a80da01d038e9853bdb7781972a2da443ad22cf89f2915f5dd3feeab030a4be8e62682aa8c472a6610537583c8d48674ff68fce5527db31
7
+ data.tar.gz: aa3fbecd9f50d93097852eaf13124c671a488afc2001ec12ec4500c46349db6be6f7b81631f44dccdc9f68e3ff0157e090018b8a615fe28662eb18bdcdb26285
data/bin/bwa_mqtt_bridge CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'mqtt'
4
+ require 'sd_notify'
4
5
 
5
6
  require 'bwa/client'
6
7
  require 'bwa/discovery'
@@ -17,6 +18,9 @@ class MQTTBridge
17
18
 
18
19
  publish_basic_attributes
19
20
 
21
+ # Tell systemd we've started up OK. Ignored if systemd not in use.
22
+ SdNotify.ready
23
+
20
24
  bwa_thread = Thread.new do
21
25
  loop do
22
26
  begin
@@ -88,6 +92,9 @@ class MQTTBridge
88
92
  (0..1).each do |i|
89
93
  publish_attribute("spa/aux#{i + 1}", message.lights[i]) if @bwa.last_control_configuration2&.aux&.[](i)
90
94
  end
95
+
96
+ # Tell systemd we are still alive and kicking. Ignored if systemd not in use.
97
+ SdNotify.watchdog
91
98
  end
92
99
  end
93
100
  end
@@ -126,7 +133,7 @@ class MQTTBridge
126
133
  next @bwa.toggle_blower if value == 'toggle'
127
134
  @bwa.set_blower(value.to_i)
128
135
  when "spa/settemperature/set"
129
- @bwa.set_temperature(value.to_i)
136
+ @bwa.set_temperature(value.to_f)
130
137
  end
131
138
  end
132
139
  end
@@ -147,7 +154,7 @@ class MQTTBridge
147
154
  end
148
155
 
149
156
  def publish_basic_attributes
150
- publish("$homie", "v4.0.0")
157
+ publish("$homie", "4.0.0")
151
158
  publish("$name", "BWA Spa")
152
159
  publish("$state", "init")
153
160
  publish("$nodes", "spa")
@@ -186,10 +193,10 @@ class MQTTBridge
186
193
  subscribe("spa/temperaturerange/set")
187
194
 
188
195
  publish("spa/currenttemperature/$name", "Current temperature")
189
- publish("spa/currenttemperature/$datatype", "integer")
196
+ publish("spa/currenttemperature/$datatype", "float")
190
197
 
191
198
  publish("spa/settemperature/$name", "Set Temperature")
192
- publish("spa/settemperature/$datatype", "integer")
199
+ publish("spa/settemperature/$datatype", "float")
193
200
  publish("spa/settemperature/$settable", "true")
194
201
  subscribe("spa/settemperature/set")
195
202
 
data/lib/bwa/client.rb CHANGED
@@ -14,8 +14,8 @@ module BWA
14
14
  @io = Net::Telnet::RFC2217.new("Host" => uri.host, "Port" => uri.port || 23, "baud" => 115200)
15
15
  @queue = []
16
16
  else
17
- require 'rubyserial'
18
- @io = Serial.new(uri.path, 115200)
17
+ require 'ccutrer-serialport'
18
+ @io = CCutrer::SerialPort.new(uri.path, baud: 115200)
19
19
  @queue = []
20
20
  end
21
21
  @buffer = ""
@@ -30,7 +30,7 @@ module BWA
30
30
  method = @io.respond_to?(:readpartial) ? :readpartial : :read
31
31
  unless message
32
32
  begin
33
- @buffer.concat(@io.send(method, 64 * 1024))
33
+ @buffer.concat(@io.__send__(method, 64 * 1024))
34
34
  rescue EOFError
35
35
  @io.wait_readable
36
36
  retry
@@ -145,7 +145,7 @@ module BWA
145
145
  # low range is 50-80 for F, 10-26 for C (by 0.5)
146
146
  def set_temperature(desired)
147
147
  desired *= 2 if last_status && last_status.temperature_scale == :celsius || desired < 50
148
- send_message("\x0a\xbf\x20#{desired.chr}")
148
+ send_message("\x0a\xbf\x20#{desired.round.chr}")
149
149
  end
150
150
 
151
151
  def set_time(hour, minute, twenty_four_hour_time = false)
data/lib/bwa/message.rb CHANGED
@@ -27,18 +27,28 @@ module BWA
27
27
  offset += 1
28
28
  return nil if data.length - offset < 5
29
29
 
30
+ # Keep scanning until message start char
30
31
  next unless data[offset] == '~'
32
+
33
+ # Read length (safe since we have at least 5 chars)
31
34
  length = data[offset + 1].ord
32
- # impossible message
33
- next if length < 5
35
+
36
+ # No message is this short or this long; keep scanning
37
+ next if length < 5 or length >= '~'.ord
34
38
 
35
39
  # don't have enough data for what this message wants;
36
- # it could be garbage on the line so keep scanning
37
- next if length + 2 > data.length - offset
40
+ # return and hope for more (yes this might cause a
41
+ # delay, but the protocol is very chatty so it won't
42
+ # be long)
43
+ return nil if length + 2 > data.length - offset
38
44
 
45
+ # Not properly terminated; keep scanning
39
46
  next unless data[offset + length + 1] == '~'
40
47
 
48
+ # Not a valid checksum; keep scanning
41
49
  next unless CRC.checksum(data.slice(offset + 1, length - 1)) == data[offset + length].ord
50
+
51
+ # Got a valid message!
42
52
  break
43
53
  end
44
54
 
@@ -56,7 +66,12 @@ module BWA
56
66
  "\xbf\x07".force_encoding(Encoding::ASCII_8BIT)].include?(message_type)
57
67
 
58
68
  if klass
59
- raise InvalidMessage.new("Unrecognized data length (#{length}) for message #{klass}", data) unless length - 5 == klass::MESSAGE_LENGTH
69
+ valid_length = if klass::MESSAGE_LENGTH.respond_to?(:include?)
70
+ klass::MESSAGE_LENGTH.include?(length - 5)
71
+ else
72
+ length - 5 == klass::MESSAGE_LENGTH
73
+ end
74
+ raise InvalidMessage.new("Unrecognized data length (#{length}) for message #{klass}", data) unless valid_length
60
75
  else
61
76
  klass = Unrecognized
62
77
  end
@@ -18,7 +18,8 @@ module BWA
18
18
  :current_temperature, :set_temperature
19
19
 
20
20
  MESSAGE_TYPE = "\xaf\x13".force_encoding(Encoding::ASCII_8BIT)
21
- MESSAGE_LENGTH = 24
21
+ # additional features have been added in later versions
22
+ MESSAGE_LENGTH = 24..32
22
23
 
23
24
  def initialize
24
25
  @src = 0xff
@@ -80,8 +81,8 @@ module BWA
80
81
  self.current_temperature = nil if self.current_temperature == 0xff
81
82
  self.set_temperature = data[20].ord
82
83
  if temperature_scale == :celsius
83
- self.current_temperature /= 2.0
84
- self.set_temperature /= 2.0
84
+ self.current_temperature /= 2.0 if self.current_temperature
85
+ self.set_temperature /= 2.0 if self.set_temperature
85
86
  end
86
87
  end
87
88
 
@@ -171,4 +172,4 @@ module BWA
171
172
  end
172
173
  end
173
174
  end
174
- end
175
+ end
data/lib/bwa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BWA
2
- VERSION = '1.1.2'
2
+ VERSION = '1.2.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balboa_worldwide_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-17 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: digest-crc
@@ -53,19 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.3
55
55
  - !ruby/object:Gem::Dependency
56
- name: rubyserial
56
+ name: ccutrer-serialport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.6.0
61
+ version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.6.0
68
+ version: 1.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: sd_notify
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.1
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: byebug
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +108,7 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '13.0'
97
- description:
111
+ description:
98
112
  email: cody@cutrer.com'
99
113
  executables:
100
114
  - bwa_mqtt_bridge
@@ -128,7 +142,7 @@ homepage: https://github.com/ccutrer/bwa
128
142
  licenses:
129
143
  - MIT
130
144
  metadata: {}
131
- post_install_message:
145
+ post_install_message:
132
146
  rdoc_options: []
133
147
  require_paths:
134
148
  - lib
@@ -144,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
158
  version: '0'
145
159
  requirements: []
146
160
  rubygems_version: 3.1.2
147
- signing_key:
161
+ signing_key:
148
162
  specification_version: 4
149
163
  summary: Library for communication with Balboa Water Group's WiFi module or RS-485
150
164
  test_files: []