Package: ambient-archiver
ambient-archiverDownload and analyse your data from ambientweather.netInstallationpip install ambient-archiverThis installsambientin your PATH.Usageambienttakes three required options:--api_key,--application_keyand--mac, which you can get from youraccount page on
ambientweather.net. You can omit the
options by settingAMBIENT_API_KEYAMBIENT_APPLICATION_KEYandAMBIENT_MACin your environment.Seeambient --helpfor more.Commandsambient backfillwrites 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 todayoverwrites .json.gz with all data since 00:00 UTCambient yesterdayoverwrites .json.gz with all data between
00:00 UTC yesterday and 23:59 UTC yesterday.backfilldoes not overwrite files. You must manually delete them if
you want fresh copies for some reason.todayandyesterdayoverwrite.Shell completionYou can optionally enable shell completion by running the appropriate command
for your shell:eval"$(_AMBIENT_COMPLETE=bash_sourceambient)">>~/.bashrc# basheval"$(_AMBIENT_COMPLETE=zsh_sourceambient)">>~/.zshrc# zsh_AMBIENT_COMPLETE=fish_sourcefoo-bar>~/.config/fish/completions/ambient.fish# fishAutomation with Github ActionsCreate a new repository, runambient backfillthen check everything inAdd these files in.github/workflows/.github/workflows/ambient.yml(ambient todayevery 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 yesterdayevery 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 pushThe 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.Push to GitHubConfigureAMBIENT_MAC,AMBIENT_API_KEYandAMBIENT_APPLICATION_KEYas
Secrets in the GitHub settings for that repository