balboa_worldwide_app 1.2.5 → 2.0.2
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 +4 -4
- data/exe/bwa_client +41 -0
- data/exe/bwa_mqtt_bridge +394 -0
- data/{bin → exe}/bwa_proxy +3 -2
- data/{bin → exe}/bwa_server +3 -2
- data/lib/balboa_worldwide_app.rb +3 -1
- data/lib/bwa/client.rb +152 -79
- data/lib/bwa/crc.rb +3 -1
- data/lib/bwa/discovery.rb +19 -17
- data/lib/bwa/logger.rb +57 -0
- data/lib/bwa/message.rb +85 -41
- data/lib/bwa/messages/configuration.rb +7 -1
- data/lib/bwa/messages/configuration_request.rb +3 -1
- data/lib/bwa/messages/control_configuration.rb +13 -9
- data/lib/bwa/messages/control_configuration_request.rb +22 -2
- data/lib/bwa/messages/filter_cycles.rb +50 -22
- data/lib/bwa/messages/ready.rb +7 -1
- data/lib/bwa/messages/{set_temperature.rb → set_target_temperature.rb} +6 -3
- data/lib/bwa/messages/set_temperature_scale.rb +6 -3
- data/lib/bwa/messages/set_time.rb +5 -2
- data/lib/bwa/messages/status.rb +61 -47
- data/lib/bwa/messages/toggle_item.rb +30 -18
- data/lib/bwa/proxy.rb +19 -19
- data/lib/bwa/server.rb +22 -19
- data/lib/bwa/version.rb +3 -1
- metadata +77 -24
- data/bin/bwa_client +0 -43
- data/bin/bwa_mqtt_bridge +0 -283
@@ -1,8 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class Configuration < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x94".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x94").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 25
|
8
|
+
|
9
|
+
def inspect
|
10
|
+
"#<BWA::Messages::Configuration>"
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
8
14
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class ConfigurationRequest < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x04".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x04").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 0
|
6
8
|
|
7
9
|
def inspect
|
@@ -1,13 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class ControlConfiguration < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x24".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x24").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 21
|
6
8
|
|
7
9
|
attr_accessor :model, :version
|
8
10
|
|
9
11
|
def initialize
|
10
|
-
|
12
|
+
super
|
13
|
+
@model = ""
|
11
14
|
@version = 0
|
12
15
|
end
|
13
16
|
|
@@ -22,15 +25,17 @@ module BWA
|
|
22
25
|
end
|
23
26
|
|
24
27
|
class ControlConfiguration2 < Message
|
25
|
-
MESSAGE_TYPE = "\xbf\x2e".force_encoding(Encoding::ASCII_8BIT)
|
28
|
+
MESSAGE_TYPE = (+"\xbf\x2e").force_encoding(Encoding::ASCII_8BIT)
|
26
29
|
MESSAGE_LENGTH = 6
|
27
30
|
|
28
|
-
attr_accessor :pumps, :lights, :
|
31
|
+
attr_accessor :pumps, :lights, :circulation_pump, :blower, :mister, :aux
|
29
32
|
|
30
33
|
def initialize
|
34
|
+
super
|
35
|
+
|
31
36
|
self.pumps = Array.new(6, 0)
|
32
37
|
self.lights = Array.new(2, false)
|
33
|
-
self.
|
38
|
+
self.circulation_pump = false
|
34
39
|
self.blower = 0
|
35
40
|
self.mister = false
|
36
41
|
self.aux = Array.new(2, false)
|
@@ -50,7 +55,7 @@ module BWA
|
|
50
55
|
lights[1] = ((flags >> 6) & 0x03 != 0)
|
51
56
|
flags = data[3].ord
|
52
57
|
self.blower = flags & 0x03
|
53
|
-
self.
|
58
|
+
self.circulation_pump = ((flags >> 6) & 0x03 != 0)
|
54
59
|
flags = data[4].ord
|
55
60
|
self.mister = (flags & 0x30 != 0)
|
56
61
|
aux[0] = (flags & 0x01 != 0)
|
@@ -58,17 +63,16 @@ module BWA
|
|
58
63
|
end
|
59
64
|
|
60
65
|
def inspect
|
61
|
-
result = "#<BWA::Messages::ControlConfiguration2 "
|
62
66
|
items = []
|
63
67
|
|
64
68
|
items << "pumps=#{pumps.inspect}"
|
65
69
|
items << "lights=#{lights.inspect}"
|
66
|
-
items << "
|
70
|
+
items << "circulation_pump" if circulation_pump
|
67
71
|
items << "blower=#{blower}" if blower != 0
|
68
72
|
items << "mister" if mister
|
69
73
|
items << "aux=#{aux.inspect}"
|
70
74
|
|
71
|
-
|
75
|
+
"#<BWA::Messages::ControlConfiguration2 #{items.join(" ")}>"
|
72
76
|
end
|
73
77
|
end
|
74
78
|
end
|
@@ -1,20 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class ControlConfigurationRequest < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x22".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x22").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 3
|
6
8
|
|
7
9
|
attr_accessor :type
|
8
10
|
|
9
11
|
def initialize(type = 1)
|
12
|
+
super()
|
10
13
|
self.type = type
|
11
14
|
end
|
12
15
|
|
13
16
|
def parse(data)
|
14
|
-
self.type = data
|
17
|
+
self.type = case data
|
18
|
+
when "\x02\x00\x00" then 1
|
19
|
+
when "\x00\x00\x01" then 2
|
20
|
+
when "\x01\x00\x00" then 3
|
21
|
+
else 0
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
25
|
+
def serialize
|
26
|
+
data = case type
|
27
|
+
when 1 then "\x02\x00\x00"
|
28
|
+
when 2 then "\x00\x00\x01"
|
29
|
+
when 3 then "\x01\x00\x00"
|
30
|
+
else "\x00\x00\x00"
|
31
|
+
end
|
32
|
+
super(data)
|
33
|
+
end
|
17
34
|
|
35
|
+
def inspect
|
36
|
+
"#<BWA::Messages::ControlConfigurationRequest #{type}>"
|
37
|
+
end
|
18
38
|
end
|
19
39
|
end
|
20
40
|
end
|
@@ -1,39 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class FilterCycles < Message
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
attr_accessor :cycle1_start_hour, :cycle1_start_minute, :cycle1_duration,
|
7
|
+
:cycle2_enabled, :cycle2_start_hour, :cycle2_start_minute, :cycle2_duration
|
8
|
+
alias_method :cycle2_enabled?, :cycle2_enabled
|
7
9
|
|
8
|
-
MESSAGE_TYPE = "\xbf\x23".force_encoding(Encoding::ASCII_8BIT)
|
10
|
+
MESSAGE_TYPE = (+"\xbf\x23").force_encoding(Encoding::ASCII_8BIT)
|
9
11
|
MESSAGE_LENGTH = 8
|
10
12
|
|
11
13
|
def parse(data)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
self.cycle1_start_hour = data[0].ord
|
15
|
+
self.cycle1_start_minute = data[1].ord
|
16
|
+
hours = data[2].ord
|
17
|
+
minutes = data[3].ord
|
18
|
+
self.cycle1_duration = (hours * 60) + minutes
|
19
|
+
|
20
|
+
c2_hour = data[4].ord
|
21
|
+
self.cycle2_enabled = !!(c2_hour & 0x80 == 0x80)
|
22
|
+
self.cycle2_start_hour = c2_hour & 0x7f
|
23
|
+
self.cycle2_start_minute = data[5].ord
|
24
|
+
hours = data[6].ord
|
25
|
+
minutes = data[7].ord
|
26
|
+
self.cycle2_duration = (hours * 60) + minutes
|
27
|
+
end
|
28
|
+
|
29
|
+
def serialize
|
30
|
+
data = cycle1_start_hour.chr
|
31
|
+
data += cycle1_start_minute.chr
|
32
|
+
data += (cycle1_duration / 60).chr
|
33
|
+
data += (cycle1_duration % 60).chr
|
34
|
+
|
35
|
+
# The cycle2 start hour is merged with the cycle2 enable.
|
36
|
+
# The high order bit of the byte is a flag to indicate this so we have
|
37
|
+
# to do a bit of different processing to set that.
|
38
|
+
# Get the filter 2 start hour
|
39
|
+
start_hour = cycle2_start_hour
|
40
|
+
|
41
|
+
# Check to see if we want filter 2 enabled (either because it changed or from the current configuration)
|
42
|
+
start_hour |= 0x80 if cycle2_enabled
|
43
|
+
|
44
|
+
data += start_hour.chr
|
45
|
+
|
46
|
+
data += cycle2_start_minute.chr
|
47
|
+
data += (cycle2_duration / 60).chr
|
48
|
+
data += (cycle2_duration % 60).chr
|
49
|
+
|
50
|
+
super(data)
|
23
51
|
end
|
24
52
|
|
25
53
|
def inspect
|
26
|
-
result = "#<BWA::Messages::FilterCycles "
|
54
|
+
result = +"#<BWA::Messages::FilterCycles "
|
27
55
|
|
28
|
-
result << "
|
29
|
-
result << self.class.format_duration(
|
56
|
+
result << "cycle1 "
|
57
|
+
result << self.class.format_duration(cycle1_duration)
|
30
58
|
result << "@"
|
31
|
-
result << self.class.format_time(
|
59
|
+
result << self.class.format_time(cycle1_start_hour, cycle1_start_minute)
|
32
60
|
|
33
|
-
result << "
|
34
|
-
result << self.class.format_duration(
|
61
|
+
result << " cycle2(#{@cycle2_enabled ? "enabled" : "disabled"}) "
|
62
|
+
result << self.class.format_duration(cycle2_duration)
|
35
63
|
result << "@"
|
36
|
-
result << self.class.format_time(
|
64
|
+
result << self.class.format_time(cycle2_start_hour, cycle2_start_minute)
|
37
65
|
|
38
66
|
result << ">"
|
39
67
|
end
|
data/lib/bwa/messages/ready.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class Ready < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\06".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\06").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 0
|
8
|
+
|
9
|
+
def inspect
|
10
|
+
"#<BWA::Messages::Ready>"
|
11
|
+
end
|
6
12
|
end
|
7
13
|
end
|
8
14
|
end
|
@@ -1,12 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
|
-
class
|
4
|
-
MESSAGE_TYPE = "\xbf\x20".force_encoding(Encoding::ASCII_8BIT)
|
5
|
+
class SetTargetTemperature < Message
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x20").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 1
|
6
8
|
|
7
9
|
attr_accessor :temperature
|
8
10
|
|
9
11
|
def initialize(temperature = nil)
|
12
|
+
super()
|
10
13
|
self.temperature = temperature
|
11
14
|
end
|
12
15
|
|
@@ -19,7 +22,7 @@ module BWA
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def inspect
|
22
|
-
"#<BWA::Messages::
|
25
|
+
"#<BWA::Messages::SetTargetTemperature #{temperature}°>"
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -1,17 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class SetTemperatureScale < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x27".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x27").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 2
|
6
8
|
|
7
9
|
attr_accessor :scale
|
8
10
|
|
9
11
|
def initialize(scale = nil)
|
12
|
+
super()
|
10
13
|
self.scale = scale
|
11
14
|
end
|
12
15
|
|
13
16
|
def parse(data)
|
14
|
-
self.scale = data[1].ord
|
17
|
+
self.scale = data[1].ord.zero? ? :fahrenheit : :celsius
|
15
18
|
end
|
16
19
|
|
17
20
|
def serialize
|
@@ -21,7 +24,7 @@ module BWA
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def inspect
|
24
|
-
"#<BWA::Messages::SetTemperatureScale
|
27
|
+
"#<BWA::Messages::SetTemperatureScale °#{scale.to_s[0].upcase}>"
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -1,12 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class SetTime < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x21".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x21").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 2
|
6
8
|
|
7
9
|
attr_accessor :hour, :minute, :twenty_four_hour_time
|
8
10
|
|
9
11
|
def initialize(hour = nil, minute = nil, twenty_four_hour_time = nil)
|
12
|
+
super()
|
10
13
|
self.hour, self.minute, self.twenty_four_hour_time = hour, minute, twenty_four_hour_time
|
11
14
|
end
|
12
15
|
|
@@ -23,7 +26,7 @@ module BWA
|
|
23
26
|
end
|
24
27
|
|
25
28
|
def inspect
|
26
|
-
"#<BWA::Messages::SetTime #{Status.format_time(hour, minute, twenty_four_hour_time)}>"
|
29
|
+
"#<BWA::Messages::SetTime #{Status.format_time(hour, minute, twenty_four_hour_time: twenty_four_hour_time)}>"
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
data/lib/bwa/messages/status.rb
CHANGED
@@ -1,58 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class Status < Message
|
4
|
-
attr_accessor :
|
6
|
+
attr_accessor :hold,
|
7
|
+
:priming,
|
5
8
|
:heating_mode,
|
6
|
-
:temperature_scale,
|
7
9
|
:twenty_four_hour_time,
|
8
|
-
:
|
10
|
+
:filter_cycles,
|
9
11
|
:heating,
|
10
12
|
:temperature_range,
|
11
13
|
:hour, :minute,
|
12
|
-
:
|
14
|
+
:circulation_pump,
|
13
15
|
:blower,
|
14
16
|
:pumps,
|
15
17
|
:lights,
|
16
18
|
:mister,
|
17
19
|
:aux,
|
18
|
-
:current_temperature,
|
20
|
+
:current_temperature,
|
21
|
+
:target_temperature
|
22
|
+
attr_reader :temperature_scale
|
23
|
+
alias_method :hold?, :hold
|
24
|
+
alias_method :priming?, :priming
|
25
|
+
alias_method :twenty_four_hour_time?, :twenty_four_hour_time
|
26
|
+
alias_method :heating?, :heating
|
19
27
|
|
20
|
-
MESSAGE_TYPE = "\xaf\x13".force_encoding(Encoding::ASCII_8BIT)
|
28
|
+
MESSAGE_TYPE = (+"\xaf\x13").force_encoding(Encoding::ASCII_8BIT)
|
21
29
|
# additional features have been added in later versions
|
22
|
-
MESSAGE_LENGTH = 24..32
|
30
|
+
MESSAGE_LENGTH = (24..32).freeze
|
23
31
|
|
24
32
|
def initialize
|
33
|
+
super
|
34
|
+
|
25
35
|
@src = 0xff
|
36
|
+
self.hold = false
|
26
37
|
self.priming = false
|
27
38
|
self.heating_mode = :ready
|
28
39
|
@temperature_scale = :fahrenheit
|
29
40
|
self.twenty_four_hour_time = false
|
30
|
-
self.
|
41
|
+
self.filter_cycles = Array.new(2, false)
|
31
42
|
self.heating = false
|
32
43
|
self.temperature_range = :high
|
33
44
|
self.hour = self.minute = 0
|
34
|
-
self.
|
45
|
+
self.circulation_pump = false
|
35
46
|
self.pumps = Array.new(6, 0)
|
36
47
|
self.lights = Array.new(2, false)
|
37
48
|
self.mister = false
|
38
49
|
self.aux = Array.new(2, false)
|
39
|
-
self.
|
50
|
+
self.target_temperature = 100
|
40
51
|
end
|
41
52
|
|
42
53
|
def parse(data)
|
54
|
+
flags = data[0].ord
|
55
|
+
self.hold = (flags & 0x05 != 0)
|
56
|
+
|
43
57
|
flags = data[1].ord
|
44
58
|
self.priming = (flags & 0x01 == 0x01)
|
45
59
|
flags = data[5].ord
|
46
60
|
self.heating_mode = case flags & 0x03
|
47
|
-
|
48
|
-
|
49
|
-
|
61
|
+
when 0x00 then :ready
|
62
|
+
when 0x01 then :rest
|
63
|
+
when 0x02 then :ready_in_rest
|
50
64
|
end
|
51
65
|
flags = data[9].ord
|
52
66
|
self.temperature_scale = (flags & 0x01 == 0x01) ? :celsius : :fahrenheit
|
53
67
|
self.twenty_four_hour_time = (flags & 0x02 == 0x02)
|
54
|
-
|
55
|
-
|
68
|
+
filter_cycles[0] = (flags & 0x04 != 0)
|
69
|
+
filter_cycles[1] = (flags & 0x08 != 0)
|
56
70
|
flags = data[10].ord
|
57
71
|
self.heating = (flags & 0x30 != 0)
|
58
72
|
self.temperature_range = (flags & 0x04 == 0x04) ? :high : :low
|
@@ -66,8 +80,8 @@ module BWA
|
|
66
80
|
pumps[5] = (flags >> 2) & 0x03
|
67
81
|
|
68
82
|
flags = data[13].ord
|
69
|
-
self.
|
70
|
-
self.blower = (flags
|
83
|
+
self.circulation_pump = (flags & 0x02 == 0x02)
|
84
|
+
self.blower = (flags >> 2) & 0x03
|
71
85
|
flags = data[14].ord
|
72
86
|
lights[0] = (flags & 0x03 != 0)
|
73
87
|
lights[1] = ((flags >> 2) & 0x03 != 0)
|
@@ -78,22 +92,22 @@ module BWA
|
|
78
92
|
self.hour = data[3].ord
|
79
93
|
self.minute = data[4].ord
|
80
94
|
self.current_temperature = data[2].ord
|
81
|
-
self.current_temperature = nil if
|
82
|
-
self.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
95
|
+
self.current_temperature = nil if current_temperature == 0xff
|
96
|
+
self.target_temperature = data[20].ord
|
97
|
+
|
98
|
+
return unless temperature_scale == :celsius
|
99
|
+
|
100
|
+
self.current_temperature /= 2.0 if current_temperature
|
101
|
+
self.target_temperature /= 2.0 if target_temperature
|
87
102
|
end
|
88
103
|
|
89
104
|
def serialize
|
90
105
|
data = "\x00" * 24
|
106
|
+
data[0] = (hold ? 0x05 : 0x00).chr
|
91
107
|
data[1] = (priming ? 0x01 : 0x00).chr
|
92
|
-
data[5] =
|
93
|
-
|
94
|
-
|
95
|
-
when :ready_in_rest; 0x02
|
96
|
-
end).chr
|
108
|
+
data[5] = { ready: 0x00,
|
109
|
+
rest: 0x01,
|
110
|
+
ready_in_rest: 0x02 }[heating_mode].chr
|
97
111
|
flags = 0
|
98
112
|
flags |= 0x01 if temperature_scale == :celsius
|
99
113
|
flags |= 0x02 if twenty_four_hour_time
|
@@ -107,7 +121,7 @@ module BWA
|
|
107
121
|
flags |= pump2 * 4
|
108
122
|
data[11] = flags.chr
|
109
123
|
flags = 0
|
110
|
-
flags |= 0x02 if
|
124
|
+
flags |= 0x02 if circulation_pump
|
111
125
|
data[13] = flags.chr
|
112
126
|
flags = 0
|
113
127
|
flags |= 0x03 if light1
|
@@ -116,10 +130,10 @@ module BWA
|
|
116
130
|
data[4] = minute.chr
|
117
131
|
if temperature_scale == :celsius
|
118
132
|
data[2] = (current_temperature ? (current_temperature * 2).to_i : 0xff).chr
|
119
|
-
data[20] = (
|
133
|
+
data[20] = (target_temperature * 2).to_i.chr
|
120
134
|
else
|
121
|
-
data[2] = (current_temperature
|
122
|
-
data[20] =
|
135
|
+
data[2] = (current_temperature.to_i || 0xff).chr
|
136
|
+
data[20] = target_temperature.to_i.chr
|
123
137
|
end
|
124
138
|
|
125
139
|
super(data)
|
@@ -129,46 +143,46 @@ module BWA
|
|
129
143
|
if value != @temperature_scale
|
130
144
|
if value == :fahrenheit
|
131
145
|
if current_temperature
|
132
|
-
self.current_temperature *= 9.0/5
|
146
|
+
self.current_temperature *= 9.0 / 5
|
133
147
|
self.current_temperature += 32
|
134
148
|
self.current_temperature = current_temperature.round
|
135
149
|
end
|
136
|
-
self.
|
137
|
-
self.
|
138
|
-
self.
|
150
|
+
self.target_temperature *= 9.0 / 5
|
151
|
+
self.target_temperature += 32
|
152
|
+
self.target_temperature = target_temperature.round
|
139
153
|
else
|
140
154
|
if current_temperature
|
141
155
|
self.current_temperature -= 32
|
142
|
-
self.current_temperature *= 5.0/90
|
156
|
+
self.current_temperature *= 5.0 / 90
|
143
157
|
self.current_temperature = (current_temperature * 2).round / 2.0
|
144
158
|
end
|
145
|
-
self.
|
146
|
-
self.
|
147
|
-
self.
|
159
|
+
self.target_temperature -= 32
|
160
|
+
self.target_temperature *= 5.0 / 9
|
161
|
+
self.target_temperature = (target_temperature * 2).round / 2.0
|
148
162
|
end
|
149
163
|
end
|
150
164
|
@temperature_scale = value
|
151
165
|
end
|
152
166
|
|
153
167
|
def inspect
|
154
|
-
result = "#<BWA::Messages::Status "
|
155
168
|
items = []
|
156
169
|
|
170
|
+
items << "hold" if hold
|
157
171
|
items << "priming" if priming
|
158
|
-
items << self.class.format_time(hour, minute, twenty_four_hour_time)
|
159
|
-
items << "#{current_temperature ||
|
160
|
-
items << "
|
172
|
+
items << self.class.format_time(hour, minute, twenty_four_hour_time: twenty_four_hour_time)
|
173
|
+
items << "#{current_temperature || "--"}/#{target_temperature}°#{temperature_scale.to_s[0].upcase}"
|
174
|
+
items << "filter_cycles=#{filter_cycles.inspect}"
|
161
175
|
items << heating_mode
|
162
176
|
items << "heating" if heating
|
163
177
|
items << temperature_range
|
164
|
-
items << "
|
165
|
-
items << "blower"
|
178
|
+
items << "circulation_pump" if circulation_pump
|
179
|
+
items << "blower=#{blower}"
|
166
180
|
items << "pumps=#{pumps.inspect}"
|
167
181
|
items << "lights=#{lights.inspect}"
|
168
182
|
items << "aux=#{aux.inspect}"
|
169
183
|
items << "mister" if mister
|
170
184
|
|
171
|
-
|
185
|
+
"#<BWA::Messages::Status #{items.join(" ")}>"
|
172
186
|
end
|
173
187
|
end
|
174
188
|
end
|
@@ -1,36 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BWA
|
2
4
|
module Messages
|
3
5
|
class ToggleItem < Message
|
4
|
-
MESSAGE_TYPE = "\xbf\x11".force_encoding(Encoding::ASCII_8BIT)
|
6
|
+
MESSAGE_TYPE = (+"\xbf\x11").force_encoding(Encoding::ASCII_8BIT)
|
5
7
|
MESSAGE_LENGTH = 2
|
8
|
+
ITEMS = {
|
9
|
+
normal_operation: 0x01,
|
10
|
+
clear_notification: 0x03,
|
11
|
+
pump1: 0x04,
|
12
|
+
pump2: 0x05,
|
13
|
+
pump3: 0x06,
|
14
|
+
pump4: 0x07,
|
15
|
+
pump5: 0x08,
|
16
|
+
pump6: 0x09,
|
17
|
+
blower: 0x0c,
|
18
|
+
mister: 0x0e,
|
19
|
+
light1: 0x11,
|
20
|
+
light2: 0x12,
|
21
|
+
aux1: 0x16,
|
22
|
+
aux2: 0x17,
|
23
|
+
hold: 0x3c,
|
24
|
+
temperature_range: 0x50,
|
25
|
+
heating_mode: 0x51
|
26
|
+
}.freeze
|
6
27
|
|
7
28
|
attr_accessor :item
|
8
29
|
|
9
30
|
def initialize(item = nil)
|
31
|
+
super()
|
10
32
|
self.item = item
|
11
33
|
end
|
12
34
|
|
13
35
|
def parse(data)
|
14
|
-
self.item =
|
15
|
-
when 0x04; :pump1
|
16
|
-
when 0x05; :pump2
|
17
|
-
when 0x11; :light1
|
18
|
-
when 0x3c; :hold
|
19
|
-
when 0x50; :temperature_range
|
20
|
-
when 0x51; :heating_mode
|
21
|
-
else; data[0].ord
|
22
|
-
end
|
36
|
+
self.item = ITEMS.invert[data[0].ord] || data[0].ord
|
23
37
|
end
|
24
38
|
|
25
39
|
def serialize
|
26
|
-
data = "\x00\x00"
|
27
|
-
data[0] =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
when :heating_mode; 0x51
|
33
|
-
end).chr
|
40
|
+
data = +"\x00\x00"
|
41
|
+
data[0] = if item.is_a? Integer
|
42
|
+
item.chr
|
43
|
+
else
|
44
|
+
ITEMS[item].chr
|
45
|
+
end
|
34
46
|
super(data)
|
35
47
|
end
|
36
48
|
|