PurpleAirDataLoggerHelpers module
Copyright 2023 carlkidcrypto, All rights reserved. A helper file that contains constants and functions for PurpleAirDataLogger* files.
- PurpleAirDataLoggerHelpers.construct_store_sensor_data_type(raw_data) list
A method to build the dict data type that the store_sensor_data method expects.
- Parameters:
raw_data (dict) – The return value from either padl_obj.request_members_data or padl_obj.request_multiple_sensors_data.
- Returns:
A list full of the dict data type that the store_sensor_data method expects.
- PurpleAirDataLoggerHelpers.flatten_single_sensor_data(raw_data) dict
A method to flatten the raw data from a single sensor request. This makes our logic downstream easier.
- Parameters:
raw_data (dict) – The return value from padl_obj.request_sensor_data.
- Returns:
A single level dict full request_sensor_data data.
- PurpleAirDataLoggerHelpers.generate_common_arg_parser(argparse_description='')
A function to generate the common arguments that all data loggers need
- Parameters:
argparse_description (str) – A description for the argument parser that will be return
- Returns:
An instance of argparse with the common arguments added.
- PurpleAirDataLoggerHelpers.logic_for_storing_group_sensors_data(padl_obj, group_id_to_use, json_config_file) int
A method containing the run loop for inserting a group sensors’ data into the data logger.
- Parameters:
padl_obj (PurpleAirDataLogger) – A valid instance of PurpleAirDataLogger.
str – The group id to be used. Starts out being None then gets filled out.
json_config_file (dict) – A dictionary object of the json config file using json load.
- Returns:
The group_id int
- PurpleAirDataLoggerHelpers.logic_for_storing_local_sensors_data(padl_obj, json_config_file) None
A method containing the run loop for inserting a local sensors’ data into the data logger.
- Parameters:
padl_obj (PurpleAirDataLogger) – A valid instance of PurpleAirDataLogger.
json_config_file (dict) – A dictionary object of the json config file using json load.
- Returns:
None
- PurpleAirDataLoggerHelpers.logic_for_storing_multiple_sensors_data(padl_obj, json_config_file) None
A method containing the run loop for inserting a multiple sensors’ data into the data logger.
- Parameters:
padl_obj (PurpleAirDataLogger) – A valid instance of PurpleAirDataLogger.
json_config_file (dict) – A dictionary object of the json config file using json load.
- Returns:
None
- PurpleAirDataLoggerHelpers.logic_for_storing_single_sensor_data(padl_obj, json_config_file) None
A method containing the run loop for inserting a single sensors’ data into the data logger.
- Parameters:
padl_obj (PurpleAirDataLogger) – A valid instance of PurpleAirDataLogger.
json_config_file (dict) – A dictionary object of the json config file using json load.
- Returns:
None
- PurpleAirDataLoggerHelpers.validate_sensor_data_before_insert(the_modified_sensor_data) dict
Before we store the data, we must make sure all fields have been included. Our psql/sqlite store statements expect all fields regardless of what we request.
- Parameters:
the_modified_sensor_data (dict) – A single layer dictionary containing a single sensors data.
return A dictionary with all the data fields filled out.