diff --git a/api/ble.py b/api/ble.py index 450524d..ecbdd05 100644 --- a/api/ble.py +++ b/api/ble.py @@ -287,7 +287,7 @@ def test(test_count = 0) -> None: log.warning(f" Test run incomplete/failed, re-running, loop {test_loop_count}. Updating test list") for sensor in sensors: temp_f = (sensor['temp'] * 1.80) + 32.0 - log.warning(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}") + log.info(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}") mac_list_new = [] for mac in mac_list: if mac not in passed_list: @@ -334,11 +334,11 @@ if __name__ == "__main__": log.info("Test run completed") for test_result in test_results: - log.info(f"Test {test_result['test_label']}:") + log.info(test_result['test_label']) parts: List[str] = [] - for reading in test_result['test_result']: - mac = reading.get("name", "") - temp = reading.get("temp", 0) + for reading in test_result['test_result']['sensor_results']: + mac = reading['name'] + temp = reading['temp'] # Grab the last two octets of the MAC address octets = mac.split(":")[-2:] short_mac = ":".join(octets) @@ -346,6 +346,44 @@ if __name__ == "__main__": result_summary = " | ".join(parts) log.info(result_summary) -# Insert before the main guard +# This is the structure of test_results +# [ +# { +# "test_label": test_label, +# "test_result": { +# "found_macs": found_macs, +# "sensor_results": [ +# { +# "name": mac, +# "temp": this_result.temperature, +# "humidity": this_result.humidity +# }, +# { +# "name": mac, +# "temp": this_result.temperature, +# "humidity": this_result.humidity +# } +# ] +# } +# }, +# { +# "test_label": test_label, +# "test_result": { +# "found_macs": found_macs, +# "sensor_results": [ +# { +# "name": mac, +# "temp": this_result.temperature, +# "humidity": this_result.humidity +# }, +# { +# "name": mac, +# "temp": this_result.temperature, +# "humidity": this_result.humidity +# } +# ] +# } +# } +# ]