server: graceful Ctrl-C shutdown; HendiCtrl closes connection cleanly
On KeyboardInterrupt, brewpi.py cancels all asyncio tasks (letting HeaterTask's `with device.open()` finally block run), then calls heater.close() as belt-and-suspenders before closing the event loop. On shutdown HeaterHendi.activate(False) now sets the switch to 0 instead of disabling remote control, so the Hendi stays in remote mode at 0 W rather than dropping back to its local panel state. HendiCtrl.close() does the same (setSwitch(0)) then closes the serial port. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ class HeaterHendi(AHeater):
|
||||
if enable:
|
||||
self.hendi.remoteEnable(1)
|
||||
else:
|
||||
self.hendi.remoteEnable(0)
|
||||
self.hendi.setSwitch(0)
|
||||
|
||||
def is_activated(self):
|
||||
s = self.hendi.isRemoteEnable()
|
||||
@@ -44,3 +44,6 @@ class HeaterHendi(AHeater):
|
||||
|
||||
def get_power(self):
|
||||
return self.power_eff
|
||||
|
||||
def close(self):
|
||||
self.hendi.close()
|
||||
|
||||
@@ -183,6 +183,13 @@ class HendiCtrl:
|
||||
def getPowerWatts(self):
|
||||
return int(self.toWatts(self.getPowerDigits()) + 0.5)
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
self.setSwitch(0)
|
||||
except Exception:
|
||||
pass
|
||||
self.ser.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
Reference in New Issue
Block a user