diff --git a/purpleair_data_logger/PurpleAirDataLogger.py b/purpleair_data_logger/PurpleAirDataLogger.py index 3e5d0e6..8238088 100644 --- a/purpleair_data_logger/PurpleAirDataLogger.py +++ b/purpleair_data_logger/PurpleAirDataLogger.py @@ -491,8 +491,9 @@ def _run_loop_for_storing_local_sensors_data(self, json_config_file) -> dict: ] # Since we want this to work for all loggers let's make an assumption. The 'SensorId' is the 'name' since it is just a MAC address. - # The 'Id' is the `sensor_index` since it is an int type and will work for all the loggers. - the_modified_sensor_data["sensor_index"] = sensor_dict["Id"] + # The 'Id' is not the `sensor_index` it increments when the data changes. It is more of a `sample_id`. Let's just use the mac as a base + # 10 number. That should be unique. + the_modified_sensor_data["sensor_index"] = int(str(sensor_dict["SensorId"]).replace(":", ""), 16) ###### Station information and status fields: ###### the_modified_sensor_data["name"] = sensor_dict["SensorId"] @@ -640,7 +641,7 @@ def _run_loop_for_storing_local_sensors_data(self, json_config_file) -> dict: the_modified_sensor_data["pm2.5"] = float( (sensor_dict["p_2_5_um"] + sensor_dict["p_2_5_um_b"]) / 2 ) - the_modified_sensor_data["pm2.5_a"] = sensor_dict["p_2_5_um_a"] + the_modified_sensor_data["pm2.5_a"] = sensor_dict["p_2_5_um"] the_modified_sensor_data["pm2.5_b"] = sensor_dict["p_2_5_um_b"] if "pm2_5_atm_b" not in sensor_dict.keys(): @@ -698,7 +699,7 @@ def _run_loop_for_storing_local_sensors_data(self, json_config_file) -> dict: the_modified_sensor_data["pm10.0"] = float( (sensor_dict["p_10_0_um"] + sensor_dict["p_10_0_um_b"]) / 2 ) - the_modified_sensor_data["pm10.0_a"] = sensor_dict["p_10_0_um_a"] + the_modified_sensor_data["pm10.0_a"] = sensor_dict["p_10_0_um"] the_modified_sensor_data["pm10.0_b"] = sensor_dict["p_10_0_um_b"] if "pm10_0_atm_b" not in sensor_dict.keys(): @@ -771,6 +772,7 @@ def _run_loop_for_storing_local_sensors_data(self, json_config_file) -> dict: requesting new data again...""" ) + del local_sensor_dict sleep(json_config_file["poll_interval_seconds"]) def _construct_store_sensor_data_type(self, raw_data) -> list: diff --git a/sample_json_config_files/sample_local_sensor_request_json_file.json b/sample_json_config_files/sample_local_sensor_request_json_file.json index 8df54e3..128d480 100644 --- a/sample_json_config_files/sample_local_sensor_request_json_file.json +++ b/sample_json_config_files/sample_local_sensor_request_json_file.json @@ -1,6 +1,7 @@ { "sensor_ip_list": [ - "192.168.1.2" + "192.168.86.24", + "192.168.86.25" ], "poll_interval_seconds": 1 } \ No newline at end of file