Closed jshank closed 2 years ago
I can turn off pumps in BWA 1.3.0 (ghcr.io/jshank/bwalink:2021.12) but nothing later (bwalink:2021.12.1 or bwalink:2021.12.2). Sorry that I never tested turning on and off pumps in the last few versions.
Interestingly enough, toggle
still works properly.
homie/bwa/spa/pump1/set toggle
homie/bwa/spa/pump1 true
homie/bwa/spa/pump1/set toggle
homie/bwa/spa/pump1 false
I'm sure it's something simple. can you set Thread.abort_on_exception = true
temporarily (in code), and hopefully it spits out an exception.
No change with Thread.abort_on_exception = true
in bwa_mqtt_bridge
line 26
The log is just filled with the ToggleItem 0 messages after the initialization
D, read: 7e 07 10 bf 11 00 00 3e 7e
bwalink | D, from spa: #<BWA::Messages::ToggleItem 0>
man, I got nothing. the configuration is clearly returning that the pump has 1 available speed (it must be 1 to publish it as a boolean to MQTT). the current pump speed is showing as true, so it's not zero. the code assumes it's going to be 1. so that's something that might be off. I'm also not sure why you're receiving toggle item messages, especially with item id 0, which the code doesn't recognize as any particular item. it feels like somehow the math in Client#set_pump is wrong causing it to send the toggle item message too many times, so you might want to add some additional logging there to see how many times it tries to toggle it.
I think I figured it out, but help me with my assumptions. The only thing you can do to a pump is call toggle (analog to pushing the button). In the code, you are trying to determine the number of times to toggle to get the pump into the desired state. It looks like the math pushes the button once for turning it on works but you have it pushed zero times for off which does nothing. I added some debugging code with the following results:
BWA Debug
W, Pump 0 speed detected as 1
W, Pump 1 speed detected as 1
W, Pump 2 speed detected as 1
W, Balboa MQTT Bridge running (version 2.0.6)
Toggled Pump 1 ON
W, Setting pump 0 to true
W, set_pump: Pump 0 setting to true
W, set_pump: Not returning
W, set_pump: false check - Changing desired to true
W, set_pump: min check - Changing desired to 1
W, set_pump: times calc - (desired: 1 - status.pumps[index]: 0) % (configuration.pumps[index]: 1 + 1) = 1
W, set_pump: Executing toggle times set to 1
W, set_pump: Calling toggle_pump on pump 0
Toggled Pump 1 off
W, Setting pump 0 to false
W, set_pump: Pump 0 setting to false
W, set_pump: Not returning
W, set_pump: false check - Changing desired to 0
W, set_pump: min check - Changing desired to 0
W, set_pump: times calc - (desired: 0 - status.pumps[index]: 2) % (configuration.pumps[index]: 1 + 1) = 0
W, set_pump: Executing toggle times set to 0
Notice the lack of a Calling toggle_pump on pump X
client.rb debug changes
def set_pump(index, desired)
BWA.logger.warn "set_pump: Pump #{index} setting to #{desired}"
return unless status && configuration
BWA.logger.warn "set_pump: Not returning"
desired = 0 if desired == false
BWA.logger.warn "set_pump: false check - Changing desired to #{desired}"
desired = configuration.pumps[index] if desired == true
desired = [desired, configuration.pumps[index]].min
BWA.logger.warn "set_pump: min check - Changing desired to #{desired}"
times = (desired - status.pumps[index]) % (configuration.pumps[index] + 1)
BWA.logger.warn "set_pump: times calc - (desired: #{desired} - status.pumps[index]: #{status.pumps[index]}) % (configuration.pumps[index]: #{configuration.pumps[index]} + 1) = #{(desired - status.pumps[index]) % (configuration.pumps[index] + 1)}"
BWA.logger.warn "set_pump: Executing toggle times set to #{times}"
times.times do
BWA.logger.warn "set_pump: Calling toggle_pump on pump #{index}"
toggle_pump(index)
sleep(0.1)
end
end
W, set_pump: times calc - (desired: 0 - status.pumps[index]: ***2***)
there it is. my assumption was that a single speed pump would return speed 1 when it's on, but it's returning speed 2, so the math is wrong. I'll get a fix up.
🤞 2.0.7 fixes it for you
Confirmed working, thanks @ccutrer!
I've lost the ability to turn pumps back off. It looks like bwa is crashing without error (logging set to debug). It seems to be related to the switch to pumps as true false instead of 0,1,2.
MQTT Logs
BWA Logs The same 2 lines repeat forever when controlling the pumps.