PurpleAirPSQLDataLogger module
Copyright 2023 carlkidcrypto, All rights reserved. A python class designed to use the PurpleAirAPI for requesting sensor(s) data. Data will be inserted into a PSQL database.
For best practice from PurpleAir: “The data from individual sensors will update no less than every 30 seconds. As a courtesy, we ask that you limit the number of requests to no more than once every 1 to 10 minutes, assuming you are only using the API to obtain data from sensors. If retrieving data from multiple sensors at once, please send a single request rather than individual requests in succession.”
- class PurpleAirPSQLDataLogger.PurpleAirPSQLDataLogger(PurpleAirAPIReadKey, PurpleAirAPIWriteKey, psql_db_conn)
Bases:
PurpleAirDataLogger
The logger class. For now we will ingest data into a TimeScaleDB PostgreSQL database. Then we will use Grafana to visualize said data.
- property get_acceptable_table_names_string_list
A getter method that will simply return the contents of the acceptable_table_names_string_list. This is a list of all the tables that this DataLogger uses and knows about.
- 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.