Skip to main content

Installation

  • Install the monitor_air_quality python package
    • This is best done in a virtualenv or with pip install --user monitor_air_quality
  • Create a ~/.config/monitor_air_quality_config.yaml file with config settings
  • Run monitor_air_quality --help to see the options

Usage

usage: monitor_air_quality.py [-h] [--fetch-local-aqi LOCATION]
                              [--fetch-notion-temperature LOCATION]
                              [--notion-sensor SENSOR_NAME]
                              [--fetch-purpleair-data LOCATION]
                              [--command COMMAND]
                              [--alert LOCATION,METRIC,THRESHOLD]
                              [--alert-on-temperature-inversion LOCATION,LOCATION]
                              [--output {print,debug,info,post}]

Gather and post or print air quality and temperature data

optional arguments:
  -h, --help            show this help message and exit
  --fetch-local-aqi LOCATION
                        the local location to use when fetching local data
  --fetch-notion-temperature LOCATION
                        the location to use when fetching the notion API for
                        temperature data
  --notion-sensor SENSOR_NAME
                        the notion sensor name to fetch from
  --fetch-purpleair-data LOCATION
                        the location to use when fetching purpleair data
  --command COMMAND     command to run to fetch remote data
  --alert LOCATION,METRIC,THRESHOLD
                        comma delimited string of location,metric,threshold
  --alert-on-temperature-inversion LOCATION,LOCATION
                        comma delimited string of indoor,outdoor location
                        names
  --output {print,debug,info,post}
                        whether to print or post the results or give debug or
                        info output (default: print)

Examples:
    --command "ssh pi@203.0.113.20 'monitor_air_quality --fetch-local-aqi upstairs'"
    --fetch-local-aqi basement --alert basement,pm25,12
    --notion-sensor "Upstairs hall Sensor" --fetch-notion-temperature upstairs
    --fetch-purpleair-data outdoor
    --alert-on-temperature-inversion upstairs,outdoor --notion-sensor "Upstairs hall Sensor" --fetch-notion-temperature upstairs --fetch-purpleair-data outdoor
    --fetch-local-aqi basement --notion-sensor "Upstairs hall Sensor" --fetch-notion-temperature upstairs --fetch-purpleair-data outdoor --command "ssh -i /home/gene/Documents/monitor_air_quality/id_rsa pi@192.168.0.31 true" --alert upstairs,pm25,12 --alert-on-temperature-inversion upstairs,outdoor

Example outputs

Output print

{
    "dt": "2021-09-12T13:25:26.460173",
    "upstairs": {
        "pm25": "4.2",
        "pm10": "7.7",
        "aqipm25": "18",
        "aqipm10": "6",
        "temp_f": "69.99"
    },
    "basement": {
        "pm25": "4.0",
        "pm10": "9.7",
        "aqipm25": "17",
        "aqipm10": "8"
    },
    "outdoor": {
        "pm25": "11.96",
        "pm10": "13.56",
        "LastSeen": 1631478276,
        "humidity": "39",
        "temp_f": "72.57",
        "pressure": "1014.62",
        "aqipm25": "50",
        "aqipm10": "12"
    }
}

Output post or info

INFO:root:Command executed : ssh pi@203.0.113.20 monitor_air_quality : {'dt': '2021-09-12T13:28:27.219094', 'upstairs': {'pm25': '3.7', 'pm10': '6.4', 'aqipm25': '15', 'aqipm10': '6'}}
INFO:root:Local air quality data fetched {'pm25': '4.0', 'pm10': '8.6', 'aqipm25': '17', 'aqipm10': '7'}
INFO:root:Notion temperature data fetched : 69.99
INFO:root:Purpleair data fetched {'pm25': '11.57', 'pm10': '12.63', 'LastSeen': 1631478516, 'humidity': '39', 'temp_f': '73.57', 'pressure': '1014.6', 'aqipm25': '48', 'aqipm10': '11'}
INFO:root:Metric upstairs pm25 3.7 continues to not exceed 12. No transition occurred
INFO:root:It continues to be warmer outside 73.57 than inside 69.99. No transition occurred

Notes

I ended up using the py-sds011 library instead of the sds011 library or just interacting with the serial device directly as it seemed to work the best for me.

I also chose to use "query mode" instead of "active mode" for the sds011 sensor, though I'm not entirely sure I understand the difference.

Sampling for 30 seconds every 5 minutes would use up 800 of the 1000 hour life of the sensor in 1 year. I will likely drop this down to 30 seconds every 10 minutes or more.

I read somewhere that the manufacturer recommends a 30 second sample but don't know where that's written.

Metadata

Release files for monitor-air-quality 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for monitor-air-quality 2.0.2
File Size Uploaded Provenance
monitor_air_quality-2.0.2.tar.gz 21.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for monitor-air-quality 2.0.2
File Interpreter ABI Platform
monitor_air_quality-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 42.5 kB

Release files / monitor_air_quality-2.0.2.tar.gz

Download URL monitor_air_quality-2.0.2.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
86177ddd58d9a1ce47c1c184465ffe297064c315098cdb595ee78591b49eabaa
BLAKE2b-256 checksum
How to use checksums
8a41ca4b4d943d7598c9fc11cbe6bd6eed79418c0fb4d2276dfa67122b247dcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

Release files / monitor_air_quality-2.0.2-py3-none-any.whl

Download URL monitor_air_quality-2.0.2-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de0ed7e836adb248594859d62baae044791f36de066e105e863d04c9ed910bd8
BLAKE2b-256 checksum
How to use checksums
a37f790bedea9d3d218b0d17e7713c011b30d78e3195e9c36bf195f3aaaec56b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

Security for monitor-air-quality 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page