Files
brewpi/components/aheater.py
T
jensandClaude Sonnet 4.6 5751d26873 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>
2026-06-30 18:26:54 +02:00

55 lines
832 B
Python

import abc
from utils.value import AttributeChange
from contextlib import contextmanager
class AHeater(AttributeChange):
def __init__(self):
AttributeChange.__init__(self)
self.is_active = False
@abc.abstractmethod
def get_power_min(self):
pass
@abc.abstractmethod
def get_power_max(self):
pass
@abc.abstractmethod
def get_powers(self):
pass
def close(self):
pass
@contextmanager
def open(self):
try:
self.activate(True)
yield None
finally:
self.activate(False)
return None
@abc.abstractmethod
def activate(self, enable):
self.is_active = enable
@abc.abstractmethod
def is_activated(self):
return self.is_active
@abc.abstractmethod
def process(self):
pass
@abc.abstractmethod
def set_power(self, power):
pass
@abc.abstractmethod
def get_power(self):
return None