PurpleAirDataLoggerHelpers module¶
Copyright 2023 carlkidcrypto, All rights reserved. A helper file that contains functions for PurpleAirDataLogger* files.
- PurpleAirDataLoggerHelpers.construct_store_sensor_data_type(raw_data) list¶
A function to build a list of dictionaries that the store_sensor_data method expects.
- Parameters:
raw_data (dict) – The return value from either
PurpleAirAPI.request_members_dataorPurpleAirAPI.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 function to flatten the raw data from a single sensor request. This makes our logic downstream easier.
- Parameters:
raw_data (dict) – The return value from
PurpleAirAPI.request_sensor_data.- Returns:
A single-level dictionary containing the flattened sensor data from a request_sensor_data call.
- 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 returned
- Returns:
An
argparse.ArgumentParserinstance with the common arguments added.
- PurpleAirDataLoggerHelpers.logic_for_storing_group_sensors_data(padl_obj, group_id_to_use, json_config_file) int¶
A function that performs one data retrieval and storage cycle for a sensor group.
- Parameters:
padl_obj (PurpleAirDataLogger) – A valid instance of PurpleAirDataLogger.
group_id_to_use (int or None) – The group id to be used. Initially
None; populated with the group id after the first call.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 function that performs one data retrieval and storage cycle for local sensors.
- 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 function that performs one data retrieval and storage cycle for multiple sensors.
- 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 function that performs one data retrieval and storage cycle for a single sensor.
- 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 store statements expect all fields regardless of what we request.
- Parameters:
the_modified_sensor_data (dict) – A single layer dictionary containing a single sensor’s data.
- Returns:
A dictionary with all the data fields filled out.