From 23d2add388e267c398c26723756996685ca208d2 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 25 Nov 2023 17:12:32 +0100 Subject: [PATCH] Added some extra counter settings to setup.py --- src/console_counter.py | 3 +-- src/setup.py | 10 ++++++++-- src/simple_hue_counter.py | 3 +-- src/smart_hue_counter.py | 5 ++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/console_counter.py b/src/console_counter.py index d9595d1..d43f633 100644 --- a/src/console_counter.py +++ b/src/console_counter.py @@ -1,8 +1,7 @@ from sensors.people_counter import PeopleCounter import logging -from setup import sensor +from setup import counter -counter = PeopleCounter(sensor) peopleCount = 0 diff --git a/src/setup.py b/src/setup.py index 69849cb..2a2d21a 100644 --- a/src/setup.py +++ b/src/setup.py @@ -1,10 +1,12 @@ -from sensors import VL53L1XSensor, VL53L3CXSensor +from sensors import VL53L1XSensor, VL53L3CXSensor, PeopleCounter from datetime import time import logging LOG_FILE_PATH = "log.txt" # Path for logs logging.getLogger().setLevel(logging.INFO) -sensor = VL53L3CXSensor() + +# If the distance (in cm) is lower or equal to this value, the people counter will trigger +MAX_TRIGGER_DISTANCE = 110 # Should lights already turn on where there is any kind of motion in the sensor ENABLE_MOTION_TRIGGERED_LIGHT = True @@ -26,3 +28,7 @@ hue_conf = { # If file exists, application is considered 'registered' at the bridge "registered_file": "smart_light_registered.bridge", } # Custom configuration for philips hue + +sensor = VL53L3CXSensor() + +counter: PeopleCounter = PeopleCounter(sensor, MAX_TRIGGER_DISTANCE) # Sensor object diff --git a/src/simple_hue_counter.py b/src/simple_hue_counter.py index 38bb607..387cac7 100644 --- a/src/simple_hue_counter.py +++ b/src/simple_hue_counter.py @@ -3,11 +3,10 @@ from services.philips_hue import PhilipsHue from sensors.people_counter import PeopleCounter import logging import json -from setup import sensor, hue_conf, LOG_FILE_PATH +from setup import hue_conf, LOG_FILE_PATH, counter hue: PhilipsHue = PhilipsHue(hue_conf) # Light interface -counter: PeopleCounter = PeopleCounter(sensor) # Sensor object peopleCount: int = 0 # Global count of people on the inside diff --git a/src/smart_hue_counter.py b/src/smart_hue_counter.py index b219205..aa821e0 100644 --- a/src/smart_hue_counter.py +++ b/src/smart_hue_counter.py @@ -1,15 +1,14 @@ from datetime import datetime, time, timedelta from typing import Optional from services.philips_hue import PhilipsHue -from sensors import PeopleCounter, Directions, VL53L1XSensor +from sensors import Directions import logging import json from timeloop import Timeloop -from setup import sensor, hue_conf, LOG_FILE_PATH, SCHEDULE, ENABLE_SCHEDULE_TRIGGERS +from setup import hue_conf, LOG_FILE_PATH, SCHEDULE, ENABLE_SCHEDULE_TRIGGERS, counter hue: PhilipsHue = PhilipsHue(hue_conf) # Light interface -counter: PeopleCounter = PeopleCounter(sensor) # Sensor object peopleCount: int = 0 # Global count of people on the inside motion_triggered_lights = False # Is light on because of any detected motion timeloop: Timeloop = Timeloop() # Used for time triggered schedule