Small improvements
This commit is contained in:
parent
6830a31454
commit
11814a211d
4 changed files with 17 additions and 13 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -161,4 +161,8 @@ cython_debug/
|
|||
|
||||
|
||||
log.txt
|
||||
.env
|
||||
.env
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/extensions.json
|
||||
.vscode/launch.json
|
||||
.vscode/settings.json
|
||||
|
|
|
@ -5,4 +5,4 @@ vl53l1x
|
|||
phue
|
||||
|
||||
# For statistics
|
||||
matplotlib
|
||||
# matplotlib
|
||||
|
|
|
@ -63,16 +63,16 @@ def count_change(change: int) -> None:
|
|||
if peopleCount <= 0 and previous_lights_state:
|
||||
# Count was 0, but lights were on => people count was not actually 0
|
||||
peopleCount = 1
|
||||
logging.debug(f"People count corrected to {peopleCount}")
|
||||
logging.info(f"People count corrected to {peopleCount}")
|
||||
elif peopleCount > 0 and not previous_lights_state:
|
||||
# Count was >0, but lights were off => people count was actually 0
|
||||
peopleCount = 0
|
||||
logging.debug(f"People count corrected to {peopleCount}")
|
||||
logging.info(f"People count corrected to {peopleCount}")
|
||||
|
||||
peopleCount += change
|
||||
if peopleCount < 0:
|
||||
peopleCount = 0
|
||||
logging.debug(f"People count changed by {change}")
|
||||
logging.info(f"People count changed by {change}")
|
||||
|
||||
# Handle light
|
||||
target_light_state = peopleCount > 0
|
||||
|
@ -100,7 +100,7 @@ def set_light_state(target_light_state: bool) -> bool:
|
|||
|
||||
# Adjust light as necessary
|
||||
hue.set_group(hue_conf["light_group"], {"on": target_light_state})
|
||||
logging.debug(f"Light state changed to {target_light_state}")
|
||||
logging.info(f"Light state changed to {target_light_state}")
|
||||
|
||||
return previous_lights_state
|
||||
|
||||
|
|
|
@ -127,16 +127,16 @@ def count_change(change: int) -> None:
|
|||
if peopleCount <= 0 and previous_lights_state and not motion_triggered_lights:
|
||||
# Count was 0, but lights were on (not because of motion triggers) => people count was not actually 0
|
||||
peopleCount = 1
|
||||
logging.debug(f"People count corrected to {peopleCount}")
|
||||
logging.info(f"People count corrected to {peopleCount}")
|
||||
elif peopleCount > 0 and not previous_lights_state:
|
||||
# Count was >0, but lights were off => people count was actually 0
|
||||
peopleCount = 0
|
||||
logging.debug(f"People count corrected to {peopleCount}")
|
||||
logging.info(f"People count corrected to {peopleCount}")
|
||||
|
||||
peopleCount += change
|
||||
if peopleCount < 0:
|
||||
peopleCount = 0
|
||||
logging.debug(f"People count changed by {change}")
|
||||
logging.info(f"People count changed by {change}")
|
||||
|
||||
# Handle light
|
||||
target_light_state = peopleCount > 0
|
||||
|
@ -201,7 +201,7 @@ def set_light_scene(target_scene: str) -> bool:
|
|||
|
||||
# Set lights to scene
|
||||
hue.set_group_scene(hue_conf["light_group"], target_scene)
|
||||
logging.debug(f"Light scene set to {target_scene}")
|
||||
logging.info(f"Light scene set to {target_scene}")
|
||||
|
||||
|
||||
def set_light_state(target_light_state: bool) -> bool:
|
||||
|
@ -223,12 +223,12 @@ def set_light_state(target_light_state: bool) -> bool:
|
|||
if target_light_state and target_scene:
|
||||
# Set to specific scene if exists
|
||||
hue.set_group_scene(hue_conf["light_group"], target_scene)
|
||||
logging.debug(
|
||||
logging.info(
|
||||
f"Light state changed to {target_light_state} with scene {target_scene}"
|
||||
)
|
||||
else:
|
||||
hue.set_group(hue_conf["light_group"], {"on": target_light_state})
|
||||
logging.debug(f"Light state changed to {target_light_state}")
|
||||
logging.info(f"Light state changed to {target_light_state}")
|
||||
|
||||
return previous_lights_state
|
||||
|
||||
|
@ -249,7 +249,7 @@ def update_scene():
|
|||
return
|
||||
|
||||
set_light_scene(scene)
|
||||
logging.debug(f"Updated scene at {datetime.now().time()} to {scene}.")
|
||||
logging.info(f"Updated scene at {datetime.now().time()} to {scene}.")
|
||||
|
||||
|
||||
def register_time_triggers():
|
||||
|
|
Loading…
Reference in a new issue