introduced config.yaml
This commit is contained in:
@@ -26,17 +26,15 @@ but may require the RRDtool development headers and a C compiler.
|
||||
```sh
|
||||
python3 -m venv .venv
|
||||
.venv/bin/pip install -r requirements.txt
|
||||
cp .env.example .env
|
||||
cp config.example.yaml config.yaml
|
||||
```
|
||||
|
||||
Add the client ID and secret for the Netatmo application **GetNetatmoData v2**
|
||||
to `.env`. Ensure `NETATMO_REDIRECT_URI` exactly matches a redirect URI configured
|
||||
for that application, then perform the initial `read_station` authorization:
|
||||
to the private `config.yaml`. Ensure `netatmo.redirect_uri` exactly matches a
|
||||
redirect URI configured for that application, then perform the initial
|
||||
`read_station` authorization:
|
||||
|
||||
```sh
|
||||
set -a
|
||||
. ./.env
|
||||
set +a
|
||||
.venv/bin/python scripts/get_netatmo_token.py
|
||||
```
|
||||
|
||||
@@ -45,43 +43,40 @@ from the browser's address bar back into the prompt. This works even if the loca
|
||||
callback page itself cannot be reached. The script exchanges the authorization
|
||||
code and writes the token file with mode `0600`.
|
||||
|
||||
The service loads `NETATMO_TOKEN_FILE` at startup. Before an access token expires,
|
||||
The service loads `netatmo.token_file` at startup. Before an access token expires,
|
||||
it refreshes it and atomically saves both the new access token and any rotated
|
||||
refresh token. Values in the token file take precedence over initial token values
|
||||
in `.env`. Client credentials remain environment-only and are never written to
|
||||
in YAML. Client credentials remain in the private configuration and are never written to
|
||||
the token file or an RRD.
|
||||
|
||||
Export the file and run Flask:
|
||||
Run the service; host, port, and URL prefix all come from `config.yaml`:
|
||||
|
||||
```sh
|
||||
set -a
|
||||
. ./.env
|
||||
set +a
|
||||
.venv/bin/flask --app wsgi run --host 0.0.0.0
|
||||
.venv/bin/python wsgi.py
|
||||
```
|
||||
|
||||
Open <http://localhost:5000/>. Keep one application worker because the polling
|
||||
With the example settings, open <http://localhost:30225/w/>. Keep one application worker because the polling
|
||||
scheduler runs inside the service process. Alternatively set
|
||||
`START_COLLECTOR=false` in web workers and invoke this from a system timer:
|
||||
`collector.enabled: false` in web workers and invoke this from a system timer:
|
||||
|
||||
```sh
|
||||
.venv/bin/flask --app wsgi collect-now
|
||||
```
|
||||
|
||||
`RRD_FOLDER` configures the database directory (default `./rrd`). The module
|
||||
variables in `.env.example` allow the five Netatmo display names to be changed.
|
||||
Set `URL_PREFIX=/w` to mount the dashboard, static assets, and every API endpoint
|
||||
`storage.rrd_folder` configures the database directory (default `./rrd`). The
|
||||
`modules` section allows the five Netatmo display names to be changed.
|
||||
Set `server.url_prefix: /w` to mount the dashboard, static assets, and every API endpoint
|
||||
below `/w`; leave it empty to serve from the site root. When a prefix is set,
|
||||
open <http://localhost:5000/w/> instead.
|
||||
|
||||
`LOG_FILE` selects a rotating application log (by default
|
||||
`logging.file` selects a rotating application log (by default
|
||||
`RRD_FOLDER/netatmo_service.log`). Every Netatmo HTTP attempt records success or
|
||||
failure, HTTP status, endpoint, and duration without credentials. Collector,
|
||||
Flask, uncaught main-thread, and uncaught worker-thread exceptions are written to
|
||||
the same log. `LOG_MAX_BYTES` defaults to 5 MiB and `LOG_BACKUP_COUNT` to five.
|
||||
the same log. `logging.max_bytes` defaults to 5 MiB and `backup_count` to five.
|
||||
The service account must have write permission on the log directory. Console
|
||||
logging remains enabled by default so `python wsgi.py` displays its listening
|
||||
address; set `LOG_CONSOLE=false` to use only the logfile.
|
||||
address; set `logging.console: false` to use only the logfile.
|
||||
|
||||
## HTTP API
|
||||
|
||||
|
||||
Reference in New Issue
Block a user