Skip to main content

Archive your data from ambientweather.net

Project description

ambient-archiver

Download and analyse your data from ambientweather.net

Installation

pip install ambient-archiver

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.

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.

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@v2
         - name: Set up Python
           uses: actions/setup-python@v2
           with:
             python-version: 3.8
         - 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@v2
         - name: Set up Python
           uses: actions/setup-python@v2
           with:
             python-version: 3.8
         - 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ambient-archiver-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ambient_archiver-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file ambient-archiver-0.1.0.tar.gz.

File metadata

  • Download URL: ambient-archiver-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for ambient-archiver-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ebd01076465eb62455f93ca512b2eab13f37b7ceaaab0dd057b65c6449fbc7fb
MD5 89f7f1e0a761ee7de9ddb356ac0128b7
BLAKE2b-256 9a62f783e5ba3b99a046b18d785f9594f2201e033a970813a3a2737d166c5016

See more details on using hashes here.

File details

Details for the file ambient_archiver-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ambient_archiver-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for ambient_archiver-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abc06ffc18957e42d6891b9db685d9ead1c93279097a5fcc64492ecdf51e1b6b
MD5 0adc149a3efa4efeb253701852bd9b9f
BLAKE2b-256 1b5122d3e0d5ef3edd99d4a621c5fb390035d61c13adb354c3945d8afce96991

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page