PurpleAirDataLogger module
Copyright 2023 carlkidcrypto, All rights reserved. A python base Data Logger class.
- class PurpleAirDataLogger.PurpleAirDataLogger(PurpleAirApiReadKey=None, PurpleAirApiWriteKey=None, PurpleAirApiIpv4Address=None)
Bases:
object
The Base Data Logger class. Will define common methods used by other data loggers. For example, PSQLDataLogger, CSVDataLogger, or SQLiteDataLogger. Inheritors of this class will only need to define their own ‘store_sensor_data’ method.
- property send_request_every_x_seconds
Return the current value of send_request_every_x_seconds. This value is how often we send requests to the Purple Air API. (PAA)
- store_sensor_data(single_sensor_data_dict)
Insert the sensor data into the database.
- Parameters:
single_sensor_data_dict (dict) – A python dictionary containing all fields for insertion. If a sensor doesn’t support a certain field make sure it is NULL and part of the dictionary. This method does no type or error checking. That is upto the caller.
- validate_parameters_and_run(paa_multiple_sensor_request_json_file=None, paa_single_sensor_request_json_file=None, paa_group_sensor_request_json_file=None, paa_local_sensor_request_json_file=None) None
A method to choose what run method to execute based on what config file is being used. This shall be considered the main entry point for and PurpleAirDataLogger.
- Parameters:
paa_multiple_sensor_request_json_file (str) – The path to a json file containing the parameters to send a single sensor request(s).
paa_single_sensor_request_json_file (str) – The path to a json file containing the parameters to send a multiple sensor request(s).
paa_group_sensor_request_json_file (str) – The path to a json file containing the parameters to send a group sensor request(s).
paa_local_sensor_request_json_file (str) – The path to a json file containing the parameters to send a local sensor request(s).
- exception PurpleAirDataLogger.PurpleAirDataLoggerError(message_string)
Bases:
Exception
Custom Exception for our PurpleAirDataLogger class.