# 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](https://ambientweather.net/account). 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 <today>.json.gz with all data since 00:00 UTC
 - `ambient yesterday` overwrites <yesterday>.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:
```bash
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/`
   <details>
   <summary><code>.github/workflows/ambient.yml</code> (<code>ambient today</code>
   every five minutes)</summary>
        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
   </details>
   <details>
   <summary><code>.github/workflows/daily.yml</code> (<code>ambient yesterday</code>
   every day at 01:00 UTC)</summary>
        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
   </details>
   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
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": "https://github.com/mikepqr/ambient-archiver",
    "name": "ambient-archiver",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "weather",
    "author": "Mike Lee Williams",
    "author_email": "mike@mike.place",
    "download_url": "https://files.pythonhosted.org/packages/75/e8/d76c684aed566508db58d5d691560108aff8bea29e540a3eb20ac936daee/ambient-archiver-0.3.0.tar.gz",
    "platform": null,
    "description": "# ambient-archiver\n\nDownload and analyse your data from ambientweather.net\n\n## Installation\n\n    pip install ambient-archiver\n\nThis installs `ambient` in your PATH.\n\n## Usage\n\n`ambient` takes three required options: `--api_key`, `--application_key` and\n`--mac`, which you can get from your [account page on\nambientweather.net](https://ambientweather.net/account). You can omit the\noptions by setting `AMBIENT_API_KEY` `AMBIENT_APPLICATION_KEY` and `AMBIENT_MAC`\nin your environment.\n\nSee `ambient --help` for more.\n\n### Commands\n\n - `ambient backfill` writes all data from 2020-01-01 to the end of the last\n   UTC day into YYYY-MM-DD.json.gz files in the present working directory (one\n   file per day)\n\n - `ambient today` overwrites <today>.json.gz with all data since 00:00 UTC\n\n - `ambient yesterday` overwrites <yesterday>.json.gz with all data between\n   00:00 UTC yesterday and 23:59 UTC yesterday.\n\n`backfill` does not overwrite files. You must manually delete them if\nyou want fresh copies for some reason. `today` and `yesterday` overwrite.\n\n### Shell completion\n\nYou can optionally enable shell completion by running the appropriate command\nfor your shell:\n\n```bash\neval \"$(_AMBIENT_COMPLETE=bash_source ambient)\" >> ~/.bashrc # bash\neval \"$(_AMBIENT_COMPLETE=zsh_source ambient)\" >> ~/.zshrc  # zsh\n_AMBIENT_COMPLETE=fish_source foo-bar > ~/.config/fish/completions/ambient.fish  # fish\n```\n\n## Automation with Github Actions\n\n1. Create a new repository, run `ambient backfill` then check everything in\n2. Add these files in `.github/workflows/`\n\n   <details>\n\n   <summary><code>.github/workflows/ambient.yml</code> (<code>ambient today</code>\n   every five minutes)</summary>\n\n        name: ambient\n\n        on:\n          workflow_dispatch:\n          # every 5 minutes\n          schedule:\n            - cron:  '*/5 * * * *'\n\n        jobs:\n          ambient:\n            runs-on: ubuntu-latest\n            steps:\n            - name: Check out repo\n              uses: actions/checkout@v3\n            - name: Set up Python\n              uses: actions/setup-python@v4\n              with:\n                python-version: 3.10\n            - name: Install Python dependencies\n              run: |\n                pip install ambient-archiver\n            - name: Overwrite since midnight\n              env:\n                AMBIENT_MAC: ${{ secrets.AMBIENT_MAC }}\n                AMBIENT_API_KEY: ${{ secrets.AMBIENT_API_KEY }}\n                AMBIENT_APPLICATION_KEY: ${{ secrets.AMBIENT_APPLICATION_KEY }}\n              run: ambient today\n            - name: Commit and push if it changed\n              run: |-\n                git config --global user.name \"scraper-bot\"\n                git config user.email \"actions@users.noreply.github.com\"\n                git add -A\n                timestamp=$(date -u)\n                git commit -m \"Scraped at ${timestamp}\" || exit 0\n                git push\n\n   </details>\n\n   <details>\n\n   <summary><code>.github/workflows/daily.yml</code> (<code>ambient yesterday</code>\n   every day at 01:00 UTC)</summary>\n\n        name: daily\n\n        on:\n          workflow_dispatch:\n          # daily, 1am UTC\n          schedule:\n            - cron:  '0 1 * * *'\n\n        jobs:\n          daily:\n            runs-on: ubuntu-latest\n            steps:\n            - name: Check out repo\n              uses: actions/checkout@v3\n            - name: Set up Python\n              uses: actions/setup-python@v4\n              with:\n                python-version: 3.10\n            - name: Install Python dependencies\n              run: |\n                pip install ambient-archiver\n            - name: Overwrite yesterday\n              env:\n                AMBIENT_MAC: ${{ secrets.AMBIENT_MAC }}\n                AMBIENT_API_KEY: ${{ secrets.AMBIENT_API_KEY }}\n                AMBIENT_APPLICATION_KEY: ${{ secrets.AMBIENT_APPLICATION_KEY }}\n              run: ambient-oy\n            - name: Commit and push if it changed\n              run: |-\n                git config --global user.name \"scraper-bot\"\n                git config user.email \"actions@users.noreply.github.com\"\n                git add -A\n                timestamp=$(date -u)\n                git commit -m \"Downloaded at at ${timestamp}\" || exit 0\n                git push\n   </details>\n\n   The daily workflow deals with the fact that the more regular job does not\n   in practice run every five minutes. It ensures the completed file for that\n   day has the last few records for the day.\n\n3. Push to GitHub\n4. Configure `AMBIENT_MAC`, `AMBIENT_API_KEY` and `AMBIENT_APPLICATION_KEY` as\n   Secrets in the GitHub settings for that repository\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Archive your data from ambientweather.net",
    "version": "0.3.0",
    "project_urls": {
        "Bug Reports": "https://github.com/mikepqr/ambient-archiver/issues",
        "Homepage": "https://github.com/mikepqr/ambient-archiver",
        "Source": "https://github.com/mikepqr/ambient-archiver"
    },
    "split_keywords": [
        "weather"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a309cac4710445e7122cae6794ab7d13856f993cbcdfcdd4b2ee20450812472",
                "md5": "e4a0ce3ad229fd2da99c6ac01f6f6e3f",
                "sha256": "fc2cb98f05913ab7d3355779405c5a9d2dffdb527edfc9a7e365d50363eb2841"
            },
            "downloads": -1,
            "filename": "ambient_archiver-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e4a0ce3ad229fd2da99c6ac01f6f6e3f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6866,
            "upload_time": "2023-06-18T17:10:15",
            "upload_time_iso_8601": "2023-06-18T17:10:15.967524Z",
            "url": "https://files.pythonhosted.org/packages/4a/30/9cac4710445e7122cae6794ab7d13856f993cbcdfcdd4b2ee20450812472/ambient_archiver-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75e8d76c684aed566508db58d5d691560108aff8bea29e540a3eb20ac936daee",
                "md5": "70e79ea71cf1d39476ff08971194361a",
                "sha256": "b79dde3c6886190fd0e290f16a96f6ad7efda0fa494799de0f781300f9ae7b33"
            },
            "downloads": -1,
            "filename": "ambient-archiver-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "70e79ea71cf1d39476ff08971194361a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6033,
            "upload_time": "2023-06-18T17:10:17",
            "upload_time_iso_8601": "2023-06-18T17:10:17.315545Z",
            "url": "https://files.pythonhosted.org/packages/75/e8/d76c684aed566508db58d5d691560108aff8bea29e540a3eb20ac936daee/ambient-archiver-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-18 17:10:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mikepqr",
    "github_project": "ambient-archiver",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ambient-archiver"
}