diff options
author | erg <uinarf@autistici.org> | 2023-03-06 11:49:59 +0100 |
---|---|---|
committer | erg <uinarf@autistici.org> | 2023-03-06 11:49:59 +0100 |
commit | 49243f99c9570e9b069b23e630707b1566c8a358 (patch) | |
tree | 0d0ca8695c3a7031ca83c3ee8aad5f3b4e1d6199 | |
parent | efe863451d901d8a3931c851be42b0d6b7370034 (diff) | |
download | Pi_Temp_PID_Control-49243f99c9570e9b069b23e630707b1566c8a358.tar.gz Pi_Temp_PID_Control-49243f99c9570e9b069b23e630707b1566c8a358.tar.bz2 Pi_Temp_PID_Control-49243f99c9570e9b069b23e630707b1566c8a358.zip |
Fixups, added .env file
-rw-r--r-- | .env | 10 | ||||
-rw-r--r-- | pi_temp_pid.py | 11 |
2 files changed, 17 insertions, 4 deletions
@@ -0,0 +1,10 @@ +kp=1 +ki=0 +kd=0 +target_temperature=24 +sample_time=15 +# todo: check both of below!: +relay_pin=22 +mosfet_pin=5 +read_retry=3 +read_frequency_sec=15 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) |