)
cfg.add_argument(
'--presence_tolerable_staleness_seconds',
type=argparse_utils.valid_duration,
default=datetime.timedelta(seconds=60 * 5),
metavar='DURATION',
)
cfg.add_argument(
'--presence_tolerable_staleness_seconds',
type=argparse_utils.valid_duration,
default=datetime.timedelta(seconds=60 * 5),
metavar='DURATION',
# Note: list most important devices first.
self.devices_by_person: Dict[Person, List[str]] = {
Person.SCOTT: [
# Note: list most important devices first.
self.devices_by_person: Dict[Person, List[str]] = {
Person.SCOTT: [
- "DC:E5:5B:0F:03:3D", # pixel6
- "6C:40:08:AE:DC:2E", # laptop
+ "DC:E5:5B:0F:03:3D", # pixel6
+ "6C:40:08:AE:DC:2E", # laptop
- "08:CC:27:63:26:14", # motog7
- "B8:31:B5:9A:4F:19", # laptop
+ "08:CC:27:63:26:14", # motog7
+ "B8:31:B5:9A:4F:19", # laptop
- "0C:CB:85:0C:8B:AE", # phone
- "D0:C6:37:E3:36:9A", # laptop
+ "0C:CB:85:0C:8B:AE", # phone
+ "D0:C6:37:E3:36:9A", # laptop
- self.location_ts_by_mac: Dict[
- Location, Dict[str, datetime.datetime]
- ] = defaultdict(dict)
+ self.location_ts_by_mac: Dict[Location, Dict[str, datetime.datetime]] = defaultdict(dict)
self.names_by_mac: Dict[str, str] = {}
self.dark_locations: Set[Location] = set()
self.names_by_mac: Dict[str, str] = {}
self.dark_locations: Set[Location] = set()
warnings.warn(msg, stacklevel=2)
self.dark_locations.add(Location.HOUSE)
warnings.warn(msg, stacklevel=2)
self.dark_locations.add(Location.HOUSE)
- def read_persisted_macs_file(
- self, filename: str, location: Location
- ) -> None:
+ def read_persisted_macs_file(self, filename: str, location: Location) -> None:
if location is Location.UNKNOWN:
return
with open(filename, "r") as rf:
if location is Location.UNKNOWN:
return
with open(filename, "r") as rf:
- (mac, count, ip_name, mfg, ts) = line.split(",")
+ (mac, _, ip_name, _, ts) = line.split(",") # type: ignore
ip_name = ip_name.strip()
match = re.match(r"(\d+\.\d+\.\d+\.\d+) +\(([^\)]+)\)", ip_name)
if match is not None:
ip_name = ip_name.strip()
match = re.match(r"(\d+\.\d+\.\d+\.\d+) +\(([^\)]+)\)", ip_name)
if match is not None:
msg = f"Can't see {self.dark_locations} right now; answer confidence impacted"
logger.warning(msg)
warnings.warn(msg, stacklevel=2)
msg = f"Can't see {self.dark_locations} right now; answer confidence impacted"
logger.warning(msg)
warnings.warn(msg, stacklevel=2)
votes: Dict[Location, int] = {}
tiebreaks: Dict[Location, datetime.datetime] = {}
credit = 10000
votes: Dict[Location, int] = {}
tiebreaks: Dict[Location, datetime.datetime] = {}
credit = 10000
for mac in self.devices_by_person[name]:
if mac not in self.names_by_mac:
continue
mac_name = self.names_by_mac[mac]
for mac in self.devices_by_person[name]:
if mac not in self.names_by_mac:
continue
mac_name = self.names_by_mac[mac]
for location in self.location_ts_by_mac:
if mac in self.location_ts_by_mac[location]:
ts = (self.location_ts_by_mac[location])[mac]
for location in self.location_ts_by_mac:
if mac in self.location_ts_by_mac[location]:
ts = (self.location_ts_by_mac[location])[mac]
- logger.debug(f'Seen {mac} ({mac_name}) at {location} since {ts}')
+ logger.debug(
+ 'Seen %s (%s) at %s since %s',
+ mac, mac_name, location, ts
+ )
bonus = credit
v = votes.get(most_recent_location, 0)
votes[most_recent_location] = v + bonus
bonus = credit
v = votes.get(most_recent_location, 0)
votes[most_recent_location] = v + bonus
- logger.debug(f'{name}: {location} gets {bonus} votes.')
- credit = int(
- credit * 0.2
- ) # Note: list most important devices first
+ logger.debug('%s: %s gets %d votes.', name, most_recent_location, bonus)
+ credit = int(credit * 0.2) # Note: list most important devices first