From 49243f99c9570e9b069b23e630707b1566c8a358 Mon Sep 17 00:00:00 2001 From: erg Date: Mon, 6 Mar 2023 11:49:59 +0100 Subject: Fixups, added .env file --- pi_temp_pid.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pi_temp_pid.py') diff --git a/pi_temp_pid.py b/pi_temp_pid.py index 8f22694..a20f8b0 100644 --- a/pi_temp_pid.py +++ b/pi_temp_pid.py @@ -149,6 +149,10 @@ if not os.path.exists(CONFIG_FILE): sys.exit() +class PidValue(BaseModel): + value: int = Field(..., ge=1, le=255) + + class ShroomboxSettings(BaseSettings): """ Shroombox settings loaded from .env file. @@ -270,12 +274,12 @@ class ShroomboxManager: def relay_switch( self, - on: bool, + on: bool = False, ) -> None: """ Turn relay on or off. :param on: bool - :return: + :return: None """ if on: logger.info('Turning on relay %time_now()') @@ -311,14 +315,13 @@ class ShroomboxManager: def mosfet_set( self, - value, + value: PidValue = 0, ) -> bool: """ Set mosfet value. :param value: int :return: bool """ - result = True logger.debug(f'Changing pin {settings.mosfet_pin} to {value}') try: self.gpio.write(settings.mosfet_pin, value) -- cgit v1.2.3-65-gdbad