Skip to content

Commit

Permalink
Merge branch 'main' into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
feijooso committed Jun 25, 2024
2 parents b12f558 + e9c82db commit 6f50b91
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/resources/rule_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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)),
Expand All @@ -49,10 +56,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 = {
Expand Down Expand Up @@ -130,7 +137,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

0 comments on commit 6f50b91

Please sign in to comment.