Skip to content

eimi-codes/cpap-monitor

💨 CPAP Monitor

Python Version License: MIT Platform Status

A beautiful, user-friendly Python application to track CPAP (Continuous Positive Airway Pressure) device maintenance schedules and sync usage data from ResMed MyAir.

Healthcare CLI Cross-Platform

📋 Table of Contents


✨ Features

Track Multiple Components - Monitor filters, hoses, and masks with automatic date calculations
Beautiful CLI Interface - Modern, colorful terminal interface with emojis and tables
MyAir Integration - Fetch and display CPAP usage data from ResMed MyAir
Daily CPAP Report - Automatically displays latest night's sleep data with component tracking
Visual Status Indicators - Color-coded status with emojis (✅ OK, ⏰ Due Soon, ⚠️ OVERDUE)
Customizable Settings - Configure replacement intervals, equipment details, and contact information
Cross-Platform Support - Works seamlessly on Windows, macOS, and Linux
Easy to Use - Simple command-line interface with helpful scripts
Automatic Calculations - Next replacement dates calculated automatically
Data Export - Export all data to JSON or YAML for analysis and backup
Persistent Storage - All data saved locally in JSON format


🚀 How to Run This App

We've made it super easy to run this app on any platform! Just follow the instructions for your operating system below.

📚 Need more detailed instructions? See our Platform-Specific Guide for comprehensive troubleshooting and advanced setup options.

Windows

Quick Start

  1. Download or clone this repository
  2. Double-click run.bat in the project folder
  3. That's it! The script will automatically:
    • Check if Python is installed
    • Install required dependencies
    • Launch the CPAP Monitor

Manual Method

If you prefer to run it manually:

# Open Command Prompt in the project folder
python cpap_monitor.py

First-Time Setup on Windows

If Python is not installed:

  1. Download Python from python.org
  2. Run the installer
  3. ⚠️ IMPORTANT: Check "Add Python to PATH" during installation
  4. Restart your computer
  5. Run run.bat again

macOS

Quick Start

  1. Download or clone this repository
  2. Open Terminal (press Cmd + Space, type "Terminal")
  3. Navigate to the project folder:
    cd /path/to/cpap-monitor
  4. Run the launcher script:
    ./run.sh

Manual Method

# Make sure you're in the project directory
python3 cpap_monitor.py

First-Time Setup on macOS

If Python is not installed:

# Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Python
brew install python3

Then run ./run.sh in the project folder.


Linux

Quick Start

  1. Download or clone this repository
  2. Open your Terminal
  3. Navigate to the project folder:
    cd /path/to/cpap-monitor
  4. Run the launcher script:
    ./run.sh

Manual Method

# Make sure you're in the project directory
python3 cpap_monitor.py

First-Time Setup on Linux

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install python3 python3-pip

Fedora/RHEL:

sudo dnf install python3 python3-pip

Arch Linux:

sudo pacman -S python python-pip

Then run ./run.sh in the project folder.


📖 Usage Guide

Basic Usage

Simply run the application to see your maintenance status:

# Windows
python cpap_monitor.py

# macOS/Linux
python3 cpap_monitor.py

# Or use the launcher scripts
run.bat       # Windows
./run.sh      # macOS/Linux

First Run: The app will automatically initialize with October 13, 2025 as the replacement date and create a beautiful status display.

Daily CPAP Report: When you have MyAir data synced, the app automatically displays your latest night's sleep data alongside component maintenance tracking. This allows you to correlate component aging with sleep quality metrics!

🌐 MyAir Integration

Step 1: Configure Your Credentials

python cpap_monitor.py --setup-myair

You'll be prompted to enter:

  • Your MyAir username/email
  • Your MyAir password
  • Your region (EU for Europe, NA for North America)

⚙️ Configure User Preferences

Customize your equipment details and contact information:

python cpap_monitor.py --setup-preferences

You can configure:

  • Equipment Information:

    • CPAP machine model (optional)
    • Mask model (optional)
    • Filter replacement interval (default: 5 months)
    • Tube/Hose replacement interval (default: 10 months)
    • Mask replacement interval (default: 10 months)
  • Contact Information:

    • Department name (optional)
    • Department address (optional)
    • Department email (optional)
    • Department phone number with country code (optional)

All fields are optional. If not configured, the app uses default values.

Step 2: Sync Your Data

python cpap_monitor.py --sync

This fetches your latest CPAP usage data from ResMed MyAir servers.

Step 3: View Your Data

The latest night's data is automatically displayed in the main view! For all historical records:

python cpap_monitor.py --show-myair

Or combine sync and display:

python cpap_monitor.py --sync --show-myair

📤 Export Your Data

Export all your CPAP data (components and MyAir records) to a file:

# Export to JSON
python cpap_monitor.py --export json

# Export to YAML (requires pyyaml: pip install pyyaml)
python cpap_monitor.py --export yaml

The exported file includes:

  • Component replacement schedules and dates
  • Complete MyAir sleep data history
  • Contact information
  • Export timestamp

This is useful for:

  • 📊 Analyzing trends over time
  • 🔄 Backing up your data
  • 📧 Sharing data with healthcare providers
  • 📈 Creating custom visualizations

🔍 Verbose Mode (Debugging)

If you encounter authentication issues or other problems with MyAir sync, enable verbose mode to see detailed debugging information:

python cpap_monitor.py --sync --verbose

Verbose mode will show:

  • Detailed error messages from the server
  • HTTP response codes and bodies
  • Authentication flow details
  • API request/response information

Example output:

[cyan]Verbose mode enabled - showing detailed debug information[/cyan]

[INFO] resmed_client: Authenticating with MyAir...
[ERROR] resmed_client: Authentication failed with status 401
[ERROR] resmed_client: Response body: {"errorCode": "E0000004", "errorSummary": "Authentication failed"}

This information is helpful for troubleshooting authentication problems or reporting issues to the developers.

📊 Output Example

When you run the app, you'll see a beautiful daily CPAP report like this:

                            💨 CPAP MAINTENANCE MONITOR                            
╔══════════════╤═════════════════╤═══════════════╤═════════════╤══════════════════╗
║ Component    │ Interval        │ Last Replaced │ Next Due    │ Status           ║
╟──────────────┼─────────────────┼───────────────┼─────────────┼──────────────────╢
║ Filters (×2) │ Every 5 months  │ 13 Oct 2025   │ 12 Mar 2026 │ ✅ OK (148 days) ║
║ Hose         │ Every 10 months │ 13 Oct 2025   │ 09 Aug 2026 │ ✅ OK (298 days) ║
║ Mask         │ Every 10 months │ 13 Oct 2025   │ 09 Aug 2026 │ ✅ OK (298 days) ║
╚══════════════╧═════════════════╧═══════════════╧═════════════╧══════════════════╝

╭──────────────────────────── 🌙 Latest Night's Sleep Data ────────────────────────────╮
│ 📅 Date: 2025-10-13                                                                  │
│ ⭐ Sleep Score: 87/100                                                               │
│ ⏰ Usage Time: 7.5 hours                                                             │
│ 💤 AHI: 2.1 events/hour                                                              │
│ 💨 Mask Leak: 8 L/min                                                                │
│ 🔄 Mask Events: 2                                                                    │
╰──────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────── Contact Information ──────────────────────────────╮
│ 📞 Service: ARI Sleep Apnea Service                                             │
│ ☎️  Phone: 01224550962                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯

The latest night's sleep data is automatically displayed when MyAir data is available, creating a comprehensive daily CPAP report that shows both component status and sleep quality metrics!


🔧 Component Replacement Schedules

Default replacement intervals are:

Component Default Interval Quantity Notes
🔵 Filters Every 5 months 2 at a time Optimized for higher pollution levels
🟢 Hose Every 10 months 1 Check for wear and tear regularly
🟡 Mask Every 10 months 1 Replace if seal is compromised

💡 Tip: You can customize these intervals using python cpap_monitor.py --setup-preferences to match your needs or your healthcare provider's recommendations.


💾 Data Storage

The application stores all data locally in JSON files:

  • maintenance_data.json - Component replacement dates and MyAir data
  • config.json - User preferences (equipment, contact info) and MyAir credentials

These files are automatically created on first run and updated as needed.

⚠️ Important: These files are excluded from version control via .gitignore to protect your privacy.


❓ FAQ

General Questions

Q: Do I need an internet connection?
A: Only if you want to sync data from ResMed MyAir. The maintenance tracking works completely offline.

Q: Will my data be sent to any servers?
A: No! All data is stored locally on your computer. When you sync MyAir data, the connection goes directly to ResMed's servers - no third parties involved.

Q: Can I change the replacement intervals?
A: Yes! Use python cpap_monitor.py --setup-preferences to configure custom replacement intervals for filters, tubes, and masks. You can also set equipment details and contact information.

Q: What if I miss a replacement date?
A: The app will show your component as ⚠️ OVERDUE in red with the number of days overdue. Replace it as soon as possible!

Q: Can I customize the contact information?
A: Yes! Use python cpap_monitor.py --setup-preferences to set your healthcare provider's contact details including name, address, email, and phone number.

Installation Issues

Q: I get "Python is not recognized" on Windows
A: Python isn't in your system PATH. Reinstall Python and make sure to check "Add Python to PATH" during installation.

Q: I get "permission denied" on macOS/Linux
A: Run chmod +x run.sh to make the script executable, then try again.

Q: The pip install command fails
A: Try using python -m pip install -r requirements.txt or python3 -m pip install -r requirements.txt instead.

MyAir Integration

Q: Is MyAir integration official?
A: No, this uses an unofficial community-discovered API. It may stop working if ResMed changes their systems.

Q: My MyAir credentials don't work
A: Make sure you're using the correct region (EU or NA) and your credentials are correct. Try logging into MyAir in a browser first to verify.

Q: Are my credentials secure?
A: Credentials are stored in plain text in config.json. Only use this on a personal, secure device. See Security & Privacy for more details.

Q: Can I use this with MyAir accounts from other regions?
A: Currently, only EU (Europe) and NA (North America) regions are supported.


🛠️ Troubleshooting

Common Issues and Solutions

Issue: Script won't run

Solution:

  1. Make sure Python 3.6+ is installed: python --version or python3 --version
  2. Check you're in the correct directory
  3. Try the manual method instead of the launcher scripts

Issue: Missing dependencies error

Solution:

# Run this in the project folder
pip install -r requirements.txt

# Or use
python -m pip install -r requirements.txt

Issue: Colors/emojis don't show correctly

Solution:

  • Windows: Use Windows Terminal (from Microsoft Store) instead of Command Prompt
  • All platforms: Make sure your terminal supports Unicode and ANSI colors

Issue: "ModuleNotFoundError: No module named 'rich'"

Solution:

pip install rich

Issue: Cannot sync MyAir data

Solution:

  1. Check your internet connection
  2. Verify credentials: python cpap_monitor.py --setup-myair
  3. Make sure you selected the correct region (EU or NA)
  4. Try logging into MyAir in a web browser to verify your account is active
  5. Use verbose mode for debugging:
    python cpap_monitor.py --sync --verbose
    This will show detailed error messages and API responses to help identify the problem.

Issue: Authentication errors with MyAir

Solution:

  1. Enable verbose mode to see detailed error information:
    python cpap_monitor.py --sync --verbose
  2. Check the error messages for specific issues:
    • 401 Unauthorized: Wrong username/password
    • MFA Required: Multi-factor authentication is not supported
    • Wrong region: Try switching between EU and NA regions
  3. Verify your credentials are correct by logging into MyAir website first

Still having issues?

Open an issue on GitHub with:

  • Your operating system and version
  • Python version (python --version)
  • Complete error message
  • What you were trying to do

📞 Contact Information

Default Contact Information
The app includes default contact information for the ARI Sleep Apnea Service. You can customize this to your healthcare provider using:

python cpap_monitor.py --setup-preferences

For technical support with the app itself, please open an issue on GitHub.


🔐 Security & Privacy

Your Data Security

Local Storage Only - All data is stored on your device
No Third-Party Servers - MyAir credentials go directly to ResMed
Open Source - You can inspect all code
⚠️ Plain Text Credentials - MyAir credentials are stored unencrypted in config.json

Important Security Notes

  1. Only use this on a personal, secure device - Don't use on shared computers
  2. Protect your config files - config.json contains your MyAir credentials
  3. Keep your system secure - Use antivirus, keep software updated
  4. Unofficial API - MyAir integration uses an unofficial API that could change

Medical Device Information

This tool is designed for use with ResMed MyAir CPAP devices that report data to:

Disclaimer: This is a maintenance tracking and data viewing tool. It is not a medical device and should not be used for medical diagnosis or treatment decisions. Always consult with your healthcare provider for medical advice.


🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Some ideas for contributions:

  • 🌍 Support for additional MyAir regions
  • 📱 Mobile app version
  • 📧 Email reminders for upcoming replacements
  • 📈 Data visualization and trends
  • 🔒 Encrypted credential storage

⚠️ Disclaimer

IMPORTANT: Please read this disclaimer carefully before using this software.

This Python program is an open-source, personal project distributed freely on GitHub. By using this software, you agree to the terms outlined below. For the complete disclaimer, see DISCLAIMER.md.

License

This software is licensed under the MIT License. The software is provided "as-is", without warranty of any kind, express or implied. The authors are not liable for any claims, damages, or liabilities arising from the use of this software.

SECURITY WARNING - PLAIN-TEXT PASSWORDS

⚠️ THIS SOFTWARE STORES PASSWORDS IN PLAIN-TEXT.

  • Use ONLY on your personal, trusted, and secured computer.
  • DO NOT use on shared, public, or untrusted computers.
  • You assume all responsibility and risk for credential security.

No Affiliation or Endorsement

This software is NOT approved, sponsored, endorsed, or affiliated with:

  • ResMed Inc. or any subsidiaries
  • Aberdeen Royal Infirmary, NHS Grampian, NHS Scotland, the National Health Service (NHS), or any healthcare/governmental bodies

This software is not a medical device and has not undergone any official review or certification.

Limitation of Liability

This is a personal project released under the MIT License. The author has no responsibility for how you use this software, the data it handles, or any consequences arising from its operation. You use this software entirely at your own risk.

Trademarks

All product names, logos, and brands are property of their respective owners. ResMed, MyAir, and other third-party trademarks belong to their rights holders. Their use does not imply affiliation or endorsement.


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

TL;DR: You can use, modify, and distribute this software freely, even for commercial purposes, as long as you include the original license and copyright notice.


🙏 Acknowledgments

  • ResMed MyAir for providing CPAP therapy data
  • resmed_myair_sensors community project for API documentation
  • Rich library for beautiful terminal formatting
  • All contributors and users of this project ❤️

Made with ❤️ for better sleep health

⭐ Star this repo if you find it helpful!

About

A python app to help users of ResMed CPAP Machines track their data and keep on top of replacement due dates

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors