Skip to main content

ambient-archiver

Download and analyse your data from ambientweather.net

Installation

pip install ambient-archiver

This installs ambient in your PATH.

Usage

ambient takes three required options: --api_key, --application_key and --mac, which you can get from your account page on ambientweather.net. You can omit the options by setting AMBIENT_API_KEY AMBIENT_APPLICATION_KEY and AMBIENT_MAC in your environment.

See ambient --help for more.

Commands

  • ambient backfill writes all data from 2020-01-01 to the end of the last UTC day into YYYY-MM-DD.json.gz files in the present working directory (one file per day)

  • ambient today overwrites .json.gz with all data since 00:00 UTC

  • ambient yesterday overwrites .json.gz with all data between 00:00 UTC yesterday and 23:59 UTC yesterday.

backfill does not overwrite files. You must manually delete them if you want fresh copies for some reason. today and yesterday overwrite.

Shell completion

You can optionally enable shell completion by running the appropriate command for your shell:

eval "$(_AMBIENT_COMPLETE=bash_source ambient)" >> ~/.bashrc # bash
eval "$(_AMBIENT_COMPLETE=zsh_source ambient)" >> ~/.zshrc  # zsh
_AMBIENT_COMPLETE=fish_source foo-bar > ~/.config/fish/completions/ambient.fish  # fish

Automation with Github Actions

  1. Create a new repository, run ambient backfill then check everything in

  2. Add these files in .github/workflows/

    .github/workflows/ambient.yml (ambient today every five minutes)
     name: ambient
    
     on:
       workflow_dispatch:
       # every 5 minutes
       schedule:
         - cron:  '*/5 * * * *'
    
     jobs:
       ambient:
         runs-on: ubuntu-latest
         steps:
         - name: Check out repo
           uses: actions/checkout@v3
         - name: Set up Python
           uses: actions/setup-python@v4
           with:
             python-version: 3.10
         - name: Install Python dependencies
           run: |
             pip install ambient-archiver
         - name: Overwrite since midnight
           env:
             AMBIENT_MAC: ${{ secrets.AMBIENT_MAC }}
             AMBIENT_API_KEY: ${{ secrets.AMBIENT_API_KEY }}
             AMBIENT_APPLICATION_KEY: ${{ secrets.AMBIENT_APPLICATION_KEY }}
           run: ambient today
         - name: Commit and push if it changed
           run: |-
             git config --global user.name "scraper-bot"
             git config user.email "actions@users.noreply.github.com"
             git add -A
             timestamp=$(date -u)
             git commit -m "Scraped at ${timestamp}" || exit 0
             git push
    
    .github/workflows/daily.yml (ambient yesterday every day at 01:00 UTC)
     name: daily
    
     on:
       workflow_dispatch:
       # daily, 1am UTC
       schedule:
         - cron:  '0 1 * * *'
    
     jobs:
       daily:
         runs-on: ubuntu-latest
         steps:
         - name: Check out repo
           uses: actions/checkout@v3
         - name: Set up Python
           uses: actions/setup-python@v4
           with:
             python-version: 3.10
         - name: Install Python dependencies
           run: |
             pip install ambient-archiver
         - name: Overwrite yesterday
           env:
             AMBIENT_MAC: ${{ secrets.AMBIENT_MAC }}
             AMBIENT_API_KEY: ${{ secrets.AMBIENT_API_KEY }}
             AMBIENT_APPLICATION_KEY: ${{ secrets.AMBIENT_APPLICATION_KEY }}
           run: ambient-oy
         - name: Commit and push if it changed
           run: |-
             git config --global user.name "scraper-bot"
             git config user.email "actions@users.noreply.github.com"
             git add -A
             timestamp=$(date -u)
             git commit -m "Downloaded at at ${timestamp}" || exit 0
             git push
    

    The daily workflow deals with the fact that the more regular job does not in practice run every five minutes. It ensures the completed file for that day has the last few records for the day.

  3. Push to GitHub

  4. Configure AMBIENT_MAC, AMBIENT_API_KEY and AMBIENT_APPLICATION_KEY as Secrets in the GitHub settings for that repository

Release files for ambient-archiver 0.3.0

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

Source distribution (sdist)

Source distribution for ambient-archiver 0.3.0
File Size Uploaded
ambient-archiver-0.3.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ambient-archiver 0.3.0
File Interpreter ABI Platform
ambient_archiver-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / ambient-archiver-0.3.0.tar.gz

Download URL ambient-archiver-0.3.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b79dde3c6886190fd0e290f16a96f6ad7efda0fa494799de0f781300f9ae7b33
BLAKE2b-256 checksum
How to use checksums
75e8d76c684aed566508db58d5d691560108aff8bea29e540a3eb20ac936daee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / ambient_archiver-0.3.0-py3-none-any.whl

Download URL ambient_archiver-0.3.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc2cb98f05913ab7d3355779405c5a9d2dffdb527edfc9a7e365d50363eb2841
BLAKE2b-256 checksum
How to use checksums
4a309cac4710445e7122cae6794ab7d13856f993cbcdfcdd4b2ee20450812472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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