Skip to content

Allows for importing myAir / ResMed data to influxDB

License

Notifications You must be signed in to change notification settings

vdbg/resmed-influx

Repository files navigation

MyAir Resmed to InfluxDB

Allows for importing MyAir data to InfluxDB.

Requirements

  • The MyAir credentials associated with the ResMed CPAP that's uploading MyAir data to the cloud
  • A device, capable of running either Docker containers or Python e.g., Raspbian or Windows
  • InfluxDB v2 installed and accessible from the device running the import
  • Bucket created on the influxDB and token available

Setup

The app reads the settings from template.config.toml, then config.toml (if it exists), then environment variables. See template.config.toml for details.

Choose one of these methods.

Using pre-built Docker image (recommended)

  1. touch config.toml
  2. This will fail due to malformed config.toml. That's intentional :) sudo docker run --name myAir -v "`pwd`/config.toml:/app/config.toml" vdbg/resmed-influx
  3. sudo docker cp myAir:/app/template.config.toml config.toml
  4. Edit config.toml by following the instructions in the file
  5. sudo docker start myAir -i -e MYAIR_INFLUX_MAIN_LOG_VERBOSITY=DEBUG This will display logging on the command window allowing for rapid troubleshooting. Ctrl-C to stop the container.
  6. When done testing the config:
  • sudo docker container rm myAir
  • sudo docker run -d --name myAir -v "`pwd`/config.toml:/app/config.toml" --restart=always --memory=100m vdbg/resmed-influx
  • To see logs: sudo docker container logs -f myAir

Using Docker image built from source

  1. git clone https://github.com/vdbg/resmed-influx.git
  2. sudo docker build -t resmed-influx-image resmed-influx/
  3. cd resmed-influx
  4. cp template.config.toml config.toml
  5. Edit config.toml by following the instructions in the file
  6. Test run: sudo docker run --name myAir -v "`pwd`/config.toml:/app/config.toml" resmed-influx-image This will display logging on the command window allowing for rapid troubleshooting. Ctrl-C to stop the container.
  7. If container needs to be restarted for testing: sudo docker start myAir -i
  8. When done testing the config:
  • sudo docker container rm myAir
  • sudo docker run -d --name myAir -v "`pwd`/config.toml:/app/config.toml" --restart=always --memory=100m resmed-influx-image
  • To see logs: sudo docker container logs -f myAir

With Docker without config file

Dependency: Docker installed.

Inspect template.config.toml file for all the settings that need to be overriden. Command will look something like:

sudo docker run \
  -d \
  --name myAir \
  --memory=100m \
  --pull=always \
  --restart=always \
  -e MYAIR_INFLUX_RESMED_LOGIN=user \
  -e MYAIR_INFLUX_RESMED_PASSWORD=password \
  -e MYAIR_INFLUX_INFLUX_TOKEN=token \
  vdbg/resmed-influx

Running directly on the device

Python 3.11+ with pip3 required. sudo apt-get install python3-pip will install pip3 on ubuntu/raspbian systems if missing.

  1. git clone https://github.com/vdbg/resmed-influx.git
  2. cd resmed-influx
  3. cp template.config.toml config.toml
  4. Edit config.toml by following the instructions in the file
  5. pip3 install -r requirements.txt
  6. Run the program:
  • Interactive mode: python3 main.py
  • Shorter: .\main.py (Windows) or ./main.py (any other OS).
  • As a background process (on non-Windows OS): python3 main.py > log.txt 2>&1 &
  1. To exit: Ctrl-C if running in interactive mode, kill the process otherwise.

Troubleshooting

The app may fail on first run, or may start failing after a long period of successful runs with a "policyNotAccepted" error. If this happens, navigate to the myAir web - ResMed site, enter your credentials, and accept myAir's policy.

Grafana

This template is what produced the following Grafana dashboard: Grafana dashboard

Note: the dashboard uses influxdb v1 compatibility mode. This page explains how to enable it.

Credits

All the myAir adapter code was copied from here.

About

Allows for importing myAir / ResMed data to influxDB

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published