X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=base_presence.py;h=405b743f90e33a85394528403f06bce71d153cc8;hb=927b6920b62d581556c12ade7e9b09dc8978296b;hp=cd62bb71892a9d7aa4f534b0411166b3e53a1d6b;hpb=5f75cf834725ac26b289cc5f157af0cb71cd5f0e;p=python_utils.git diff --git a/base_presence.py b/base_presence.py index cd62bb7..405b743 100755 --- a/base_presence.py +++ b/base_presence.py @@ -5,6 +5,7 @@ from collections import defaultdict import logging import re from typing import Dict, List, Set +import warnings # Note: this module is fairly early loaded. Be aware of dependencies. import argparse_utils @@ -42,7 +43,7 @@ class PresenceDetection(object): # Note: list most important devices first. self.devices_by_person: Dict[Person, List[str]] = { Person.SCOTT: [ - "3C:28:6D:10:6D:41", # pixel3 + "DC:E5:5B:0F:03:3D", # pixel6 "6C:40:08:AE:DC:2E", # laptop ], Person.LYNN: [ @@ -113,7 +114,9 @@ class PresenceDetection(object): self.parse_raw_macs_file(raw, Location.CABIN) except Exception as e: logger.exception(e) - logger.warning("Can't see the cabin right now; presence detection impared.") + msg = "Can't see the cabin right now; presence detection impared." + warnings.warn(msg) + logger.warning(msg, stacklevel=2) self.dark_locations.add(Location.CABIN) def update_from_cabin(self) -> None: @@ -131,7 +134,9 @@ class PresenceDetection(object): self.parse_raw_macs_file(raw, Location.HOUSE) except Exception as e: logger.exception(e) - logger.warning("Can't see the house right now; presence detection impared.") + msg = "Can't see the house right now; presence detection impared." + logger.warning(msg) + warnings.warn(msg, stacklevel=2) self.dark_locations.add(Location.HOUSE) def read_persisted_macs_file( @@ -193,9 +198,9 @@ class PresenceDetection(object): def where_is_person_now(self, name: Person) -> Location: self.maybe_update() if len(self.dark_locations) > 0: - logger.warning( - f"Can't see {self.dark_locations} right now; answer confidence impacted" - ) + msg = f"Can't see {self.dark_locations} right now; answer confidence impacted" + logger.warning(msg) + warnings.warn(msg, stacklevel=2) logger.debug(f'Looking for {name}...') if name is Person.UNKNOWN: @@ -242,8 +247,8 @@ def main() -> None: for person in Person: print(f'{person} => {p.where_is_person_now(person)}') print() - for location in Location: - print(f'{location} => {p.is_anyone_in_location_now(location)}') +# for location in Location: +# print(f'{location} => {p.is_anyone_in_location_now(location)}') if __name__ == '__main__':