diff --git a/ble.py b/ble.py index 74191eb..ad078b7 100644 --- a/ble.py +++ b/ble.py @@ -48,9 +48,9 @@ async def read_data(mac_address): await asyncio.sleep(0.1) while not success: try: - print("Client connected, getting services") + print("..Client connected, getting services") services = client.services - print("Services acquired, loading uuid matches") + print("..Services acquired, loading uuid matches") mi_service = next((s for s in services if s.uuid.lower() == MI_SERVICE_UUID.lower()), None) success = True #print("uuid matches loaded") @@ -69,7 +69,6 @@ async def read_data(mac_address): hum = sensor_data[2] print(f"-- Temperature: {temp:.1f}°C, Humidity: {hum}%") - print("") return temp, hum def sensor_data_query(mac_list): diff --git a/scanner.py b/scanner.py index e284834..d7f186e 100644 --- a/scanner.py +++ b/scanner.py @@ -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, diff --git a/sensors.py b/sensors.py index ef790d3..c09c9ad 100644 --- a/sensors.py +++ b/sensors.py @@ -76,7 +76,7 @@ class Sensor: def __post_init__(self) -> None: """Initialise timestamps when the object is created.""" - print(f"Instantiating new sensor object - {self.name}") + # print(f"Instantiating new sensor object - {self.name}") ts = _current_timestamp() self.first_seen = ts self.last_seen = ts