print line cleanup 2
This commit is contained in:
1 parent
91640964cd
commit
f00ba3fefc
3 files changed
+11
-11
No files matched your search
+8
-7
@@ -100,16 +100,16 @@ def update_cache() -> None:
|
||||
# Gets the MACs
|
||||
print("--- Starting update_cache loop ---")
|
||||
new_macs = scan_macs()
|
||||
print(f"[Scanner] Updated cache, {len(_mac_cache)} unique MAC(s).")
|
||||
print("Updating data for current MACs...")
|
||||
# now that we have MACs, let's get sensor data
|
||||
print("Updating sensor data...")
|
||||
sensor_data = None
|
||||
try:
|
||||
sensor_data = sensor_data_query(new_macs)
|
||||
print(sensor_data)
|
||||
# print(sensor_data)
|
||||
except Exception as e:
|
||||
print(f"Aww fuck, no data :( - {e}")
|
||||
# now we update the data in the sensor objects
|
||||
print("Sensor data collected:")
|
||||
for sensor_datum in sensor_data:
|
||||
print(f"MAC - {sensor_datum['name']} | temp - {sensor_datum['temp']} | humidity - {sensor_datum['humidity']}")
|
||||
for sensor in _sensors_cache:
|
||||
@@ -123,15 +123,16 @@ def update_cache() -> None:
|
||||
|
||||
# this helper function scans for MACs
|
||||
def scan_macs():
|
||||
print("Scanning for MACs:")
|
||||
new_macs = asyncio.run(_scan_once())
|
||||
with _lock:
|
||||
print("MACs found:")
|
||||
with _lock:
|
||||
for new_mac in new_macs:
|
||||
print(f"{new_mac}")
|
||||
new_sensor = Sensor(name=f"{new_mac}")
|
||||
if new_mac not in set(_mac_cache):
|
||||
_sensors_cache.append(new_sensor)
|
||||
_mac_cache.update(new_macs)
|
||||
print(f"Found {len(new_macs)} new MACs, total {len(_mac_cache)} MACs in cache.")
|
||||
return new_macs
|
||||
|
||||
# return just the MACs
|
||||
@@ -149,7 +150,7 @@ def get_sensor_details(friendly_date = False):
|
||||
if friendly_date:
|
||||
first_seen = ts_to_pst_string(sensor.first_seen)
|
||||
last_seen = ts_to_pst_string(sensor.last_seen)
|
||||
print(f"Summary - {sensor.name}")
|
||||
# print(f"Summary - {sensor.name}")
|
||||
new_sensor = {
|
||||
"name": sensor.name,
|
||||
"first_seen": first_seen,
|
||||
@@ -168,7 +169,7 @@ def get_sensor_details(friendly_date = False):
|
||||
def get_sensor_summary():
|
||||
sensor_list = []
|
||||
for sensor in _sensors_cache:
|
||||
print(f"Summary - {sensor.name}")
|
||||
# print(f"Summary - {sensor.name}")
|
||||
new_sensor = {
|
||||
"name": sensor.name,
|
||||
"comment": sensor.comment,
|
||||
|
||||
Reference in new issue
Block a user