From e9c82db3006375c29e3e3c0077f47be7f5d5b52c Mon Sep 17 00:00:00 2001 From: Sofia Date: Sat, 22 Jun 2024 01:15:58 -0300 Subject: [PATCH] Light values (#30) * try fix light values * rmv log * night values --- app/resources/rule_parser.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/resources/rule_parser.py b/app/resources/rule_parser.py index 04940d5..3538510 100644 --- a/app/resources/rule_parser.py +++ b/app/resources/rule_parser.py @@ -34,6 +34,13 @@ def check_t_rule( return is_deviated(register, night_value - DELTA, night_value + DELTA) +def check_l_rule(register, min, max) -> Optional[Literal["lower", "higher"]]: + if not is_daytime(): + return is_deviated(register, 0, max) + + return is_deviated(register, min, max) + + TEMP_RULES_MAP = { 1: (check_t_rule, (10, 18)), 2: (check_t_rule, (18, 24)), @@ -48,10 +55,10 @@ def check_t_rule( # FOOT CANDLE (ftc) LIGHT_RULES_MAP = { - 1: (is_deviated, (350, 500)), - 2: (is_deviated, (200, 350)), - 3: (is_deviated, (75, 200)), - 4: (is_deviated, (25, 75)), + 1: (check_l_rule, (500, 10000)), + 2: (check_l_rule, (200, 500)), + 3: (check_l_rule, (75, 200)), + 4: (check_l_rule, (25, 75)), } WATERING_RULES_MAP = { @@ -129,7 +136,4 @@ def apply_humidity_rule(rule, register): def is_daytime(): now = datetime.now() - current_hour = now.hour - daytime_start_hour = 6 - daytime_end_hour = 18 - return daytime_start_hour <= current_hour <= daytime_end_hour + return 6 <= now.hour <= 18