hms-homelab/hms-cpap
Über uns
Lightweight, fully local CPAP data viewer. Reads ResMed, Philips DreamStation 2, Löwenstein, Sefam and BMC Luna via Sleep Bridge Lite, WiFi SD card, Bluetooth or SD card/folder. 13 signal charts (live where supported), events, trends, PDF reports, Wellue O2Ring overlay. Runs on Windows, Mac, Linux, Pi, Docker or Home Assistant with 47+ sensors.
Systeme und InfrastrukturWhat you can do
- Dashboard with the key numbers per night, 30-day trends, pressure gauges, and a per-night CpapDash Index (usage + AHI + leak in one number)
- Session detail with 13 zoomable signal charts, event markers, and live view while you sleep (ResMed, Luna, and a DreamStation card whose files are not encrypted); a minute the machine did not measure is left empty, never drawn as 0
- Luna flow and pressure charts, per minute, growing live while the night is written through a Sleep Bridge Lite
- DreamStation live flow from a card whose files are not encrypted: flow, breathing rate and I:E while the session is open, the pressure chart saying "Pressure arrives when the session ends", and the delivered pressure after mask-off
Gemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- +3
- in 15 days
- +5
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalHMS-CPAP
A small, local-only CPAP data viewer. Reads your machine's SD card, shows you your nights in a web dashboard, and (optionally) publishes them to Home Assistant.
Not a medical device
HMS-CPAP is a hobbyist data viewer. It is not a medical device, is not cleared by any regulator, and cannot diagnose anything or tell you whether your therapy is working. Never change your therapy settings based on this software. Talk to the clinician who manages your therapy. The numbers can be wrong: the parsers read undocumented, reverse-engineered formats.
Read DISCLAIMER.md before using this. By using it you accept the Terms of Use. Not affiliated with ResMed, Philips, Löwenstein, Sefam, BMC, React Health, SleepHQ, or anyone else named here. See NOTICE.

What it is
A C++ service with a built-in Angular web UI. It takes the files your CPAP writes to its SD card (from a Sleep Bridge Lite listening on the card, from the machine's own Bluetooth, over WiFi from an ez Share or Toshiba FlashAir card, or from a folder), parses them itself, stores the results in a database, and shows you the data. It is a fully local-first experience.
Supported machines
| Manufacturer | Models |
|---|---|
| ResMed | AirSense 10, AirSense 11, AirCurve 10, AirCurve 11 |
| Philips | DreamStation 2 |
| BMC / React Health | Luna |
| Löwenstein | Prisma Line (20A, 20C, 25S, 25ST), Prisma Smart (Max, Plus, Soft) |
| Sefam | S.Box AUTO (1263R), SleepBox AUTO (1200R) |
How each machine gets here
| Machine | Card reader or upload page | Sleep Bridge Lite | Bluetooth from this computer | Mule & Miner (Bluetooth) | Mule & Miner (WiFi SD card, ez Share) | Toshiba FlashAir |
|---|---|---|---|---|---|---|
| ResMed AirSense 10 | ✅ after the night | ✅ live | ❌ | ❌ | ✅ live | ✅ live |
| ResMed AirSense 11 | ✅ after the night | ✅ live | ✅ live | ✅ live | ✅ live | Not tested yet |
| ResMed AirCurve 10 | ✅ after the night | ✅ live | ❌ | ❌ | ✅ live | ✅ live |
| ResMed AirCurve 11 | ✅ after the night | ✅ live | ✅ live | ✅ live | ✅ live | Not tested yet |
| Philips DreamStation 2 | ✅ after the night, through OSCAR | ✅ live, through OSCAR | ✅ after the night | ✅ after the night | ❌ | ❌ |
| BMC / React Health Luna | ✅ after the night | ✅ live | ❌ | ❌ | ✅ after the night | Not tested yet |
| Löwenstein prisma20A (Prisma Line) | ✅ after the night | Not tested yet | ❌ | ❌ | ❌ | ❌ |
| Löwenstein Prisma Line (20C, 25S, 25ST), Prisma Smart | ✅ after the night | ❌ | ❌ | ❌ | ❌ | ❌ |
| Sefam S.Box, SleepBox | ✅ after the night | Not tested yet | ❌ | ❌ | Not tested yet | Not tested yet |
✅ live: charts update during therapy. ✅ after the night: the night arrives once it has ended. ❌: not supported. Not tested yet: the code reads it, not yet shown on a real machine. What each machine gives you, and why: What each machine gives you in HMS-CPAP.
Features
- Dashboard with the key numbers per night, 30-day trends, pressure gauges, and a per-night CpapDash Index (usage + AHI + leak in one number)
- Session detail with 13 zoomable signal charts, event markers, and live view while you sleep (ResMed, Luna, and a DreamStation card whose files are not encrypted); a minute the machine did not measure is left empty, never drawn as 0
- Luna flow and pressure charts, per minute, growing live while the night is written through a Sleep Bridge Lite
- DreamStation live flow from a card whose files are not encrypted: flow, breathing rate and I:E while the session is open, the pressure chart saying "Pressure arrives when the session ends", and the delivered pressure after mask-off
- Events explorer: every respiratory event across all nights, filterable by date, type, and duration
- PDF reports for a date range, made for handing to your doctor
- Pulse oximetry: Wellue O2Ring SpO2/HR overlay with ODI, imported by CSV upload
- Sleep Bridge Lite receiver: a bridge on the SD card's wires sends every write to hms-cpap as the machine makes it, and the card's files are rebuilt here, live
- AirSense 11 over Bluetooth (off by default): this computer pairs with the machine itself and reads its daily summary and its live night, no card involved, on macOS, Windows and Linux; a Mule & Miner in the same mode can send the night here instead
- Philips DreamStation 2 over Bluetooth (off by default): read after the night from this computer's Bluetooth or through a Mule & Miner, once a day at your time or when you ask
- Manual upload page: drag in a CPAP
.zipor O2Ring.csvfrom any browser, no shared network needed - Home Assistant: 47+ sensors via MQTT auto-discovery, or install it as an add-on and run it inside HA
- Equipment & supply reminders: track mask, filters, tubing per profile; days-left sensors and due/overdue events for automations
- SleepHQ export (off by default): forward each finished night to SleepHQ
- ResMed myAir comparison (off by default, read-only): put ResMed's own nightly score next to CpapDash's
- LLM night summaries (off by default): plain-language write-ups via Ollama or any OpenAI-compatible endpoint
- Local sleep model (on by default, can be switched off in Settings): each night's summary written on this machine, with no network, by a small model of its own (narrator-v1, 47 MB, included in every package and built in through llama.cpp). Every night that lands gets one, from the bridge, Bluetooth, a card upload or a re-read. Every number it writes is checked against the night's stored facts, and a plain template is used instead when the text does not pass. Under a second on a desktop, under a minute on a Pi Zero 2 W
- Machine clock per machine: a machine kept on another time zone or a fixed offset has its nights stored and published on its own clock; the card on the Devices page offers the offset its files show
- Usage target (Settings, 4 hours by default): the dashboard's usage goal, set to what your plan asks
- OSCAR helper on a home PC: hms-cpap in Docker or the Home Assistant add-on gets a DreamStation 2 card read by the OSCAR on a Windows, macOS or Linux PC at home
- ML insights (off by default): AHI prediction, compliance forecast, mask-fit risk, anomaly detection
- Any database: SQLite (default, zero setup), PostgreSQL, or MySQL/MariaDB
- Runs on Windows, macOS, Linux, Raspberry Pi, Docker, or as a Home Assistant add-on
Install
Pick one. Every path ends at the same five-step setup wizard in your browser: a welcome, where to store data, where the data comes from, which optional extras to turn on (and whether to start at login or at boot), and a last step that applies it all.
Home Assistant add-on (easiest if you run HA)
Settings -> Apps -> three dots -> Repositories, add:
https://github.com/hms-homelab/hms-cpap-ha-addon
Install CpapDash, start it, and the wizard opens through Ingress. No port to open, no second password; the MQTT broker's credentials are picked up automatically.
Windows
Download HmsCpapInstaller-Setup.exe from
Releases and run it. No
admin rights needed. A tray icon gives you Open Dashboard, Sync Now, and Start
at Login.
macOS
Download hms-cpap-macos-arm64.zip from
Releases, unzip, run:
./hms_cpap
Your browser opens on http://localhost:8893/setup.
Raspberry Pi and Linux (Docker)
The image on GHCR is built for arm64 and amd64, so it runs as-is on a
64-bit Pi 3/4/5 or any x86 Linux box. Nothing to compile.
docker run -d --name hms-cpap -p 8893:8893 \
-e TZ=America/New_York \
-v cpap_config:/config -v cpap_data:/data \
ghcr.io/hms-homelab/hms-cpap:latest
Open http://localhost:8893/setup. Config lives in the cpap_config volume and
data in cpap_data; neither is touched by image updates.
Set TZ to your own time zone (the compose file reads it from your shell or
.env). The CPAP keeps local time with no zone, and hms-cpap reads it in the
container's: a container left on UTC files a night that started at 1 AM as
1 AM UTC, and Home Assistant shows its times with +00:00. The log's
configuration block prints the zone in use. The Home Assistant add-on needs
nothing: the Supervisor gives it Home Assistant's own time zone.
For a Sleep Bridge Lite or a Mule & Miner sending a night here, publish the
stream port as well: add -p 8894:8894 to the line above (the compose file
already does).
To read an O2Ring or an AirSense 11 over the host's own Bluetooth, give the
container the host's D-Bus as well: add -v /run/dbus:/run/dbus:ro to the
line above. Without it everything else runs and Settings says there is no
Bluetooth adapter.
If you'd rather have PostgreSQL and an MQTT broker alongside it, clone the repo
and run docker compose up -d instead; it brings up all three and waits for
the database before starting CpapDash.
A Pi that already runs Home Assistant can skip Docker entirely and use the add-on above.
Linux (build from source)
git clone https://github.com/hms-homelab/hms-cpap.git
cd hms-cpap
./build_and_deploy.sh # installs what is missing, builds frontend + backend, runs tests
./build_and_deploy.sh --deploy # the same, then installs the binary
build_and_deploy.sh checks everything in the table below first, then
installs whatever is missing or too old, showing each command before it runs
it (sudo asks for your password as usual): apt-get on Debian and Ubuntu,
Node.js 22 from NodeSource (never the distribution's nodejs, which is 18 on
Ubuntu 24.04), and Homebrew on macOS. Drogon must be 1.9.11 or later, the
first release that answers a WebSocket message sent in fragments (a Sleep
Bridge's hello is), so apt's libdrogon-dev (1.8.7 on Ubuntu 24.04, none on
Debian 12) is never used. A Drogon 1.9.11 or later already installed
(Homebrew's, for one) is used as it is; otherwise the script builds upstream
v1.9.14 from source, static, into ~/.local/opt/hms-cpap-deps, and skips that
build on later runs. Then it checks again and builds.
It stops only on a conflict it must not resolve on its own (a held or
conflicting package, a release without a package, a system without apt or
Homebrew, or on macOS a Homebrew drogon older than 1.9.11 linked into the
Homebrew include directory, whose headers would shadow the one built here:
brew upgrade drogon), and then says what conflicts and what to do.
--validate-deps(or--check) only checks: it prints the table with what is installed and what is missing, installs and builds nothing, and exits 1 when something is missing.--skip-febuilds the backend only and needs no Node.js.
When a build step still fails because something is missing, the script names
it ("Missing dependency: ...") above the end of that step's log; the full logs
are in build/logs/.
What the build needs, and why (the script carries the same list):
| Requirement | Minimum | Needed for | When | Package (Debian / Ubuntu apt) |
|---|---|---|---|---|
| CMake | 3.16 | configures the build | always | cmake |
| C++ compiler | C++17, with <filesystem> |
compiles hms-cpap | always | build-essential |
| C compiler | llama.cpp's ggml (the local sleep model) | always | build-essential |
|
| make | runs the build | always | build-essential |
|
| git | CMake downloads the parser, cpapdash-ds2-ble, miniz, hms-shared and llama.cpp | always | git |
|
| CA certificates | those downloads are HTTPS | always | ca-certificates |
|
| time zone database | the machine's time zone, at run time and in the tests | always | tzdata |
|
| Drogon | 1.9.11 | the web server and web UI | always | v1.9.14 built from source by the script (not libdrogon-dev) |
| jsoncpp | JSON for the API and config, and Drogon | always | libjsoncpp-dev |
|
| libcurl | HTTP client | always | libcurl4-openssl-dev |
|
| OpenSSL | TLS and hashing, and Drogon | always | libssl-dev |
|
| SQLite | the default database | always | libsqlite3-dev |
|
| libpq | PostgreSQL support (on by default) | always | libpq-dev |
|
| libpqxx | PostgreSQL support (on by default) | always | libpqxx-dev |
|
| libharu | PDF reports | always | libhpdf-dev |
|
| nlohmann/json | JSON | always | nlohmann-json3-dev |
|
| spdlog | logging | always | libspdlog-dev |
|
| Paho MQTT C | MQTT (Home Assistant) | always | libpaho-mqtt-dev |
|
| Paho MQTT C++ | MQTT (Home Assistant) | always | libpaho-mqttpp-dev (macOS: built from source by the script) |
|
| GoogleTest, GoogleMock | the unit tests the script runs | always | libgtest-dev libgmock-dev |
|
| zlib, Brotli | Drogon | always | zlib1g-dev libbrotli-dev |
|
| uuid | Drogon | Linux | uuid-dev |
|
| Node.js | 20.19, 22.12 or 24 | builds the web UI | not with --skip-fe |
NodeSource, not Ubuntu's nodejs (18, too old) |
| npm | 8 | installs the web UI's packages | not with --skip-fe |
comes with Node.js |
| sdbus-c++ | direct Bluetooth LE (BlueZ) | only with -DBUILD_WITH_BLE=ON |
libsdbus-c++-dev |
|
| MySQL / MariaDB client | MySQL support | only with -DBUILD_WITH_MYSQL=ON |
libmariadb-dev |
|
| gnuplot | the charts in PDF reports | optional, at run time | gnuplot |
On Ubuntu 24.04 the script's install is:
sudo apt-get update
sudo apt-get install -y cmake build-essential git libjsoncpp-dev libcurl4-openssl-dev \
libssl-dev libsqlite3-dev libpq-dev libpqxx-dev libhpdf-dev nlohmann-json3-dev \
libspdlog-dev libpaho-mqtt-dev libpaho-mqttpp-dev libgtest-dev libgmock-dev \
uuid-dev zlib1g-dev libbrotli-dev ca-certificates tzdata
then Node.js 22 from NodeSource and the Drogon build.
Or without the script, backend only, once the script has built Drogon:
mkdir build && cd build && cmake -DCMAKE_PREFIX_PATH=$HOME/.local/opt/hms-cpap-deps .. && make -j$(nproc) && ./hms_cpap.
Getting the data off the machine
There are five ways to get the nights in. The first is the one to pick if you are starting today; the others are here for the hardware you already have. Whatever the way, the result is the same: card files on this computer, parsed by hms-cpap.
ResMed AirSense 11 with REF 39517 on the label underneath: its SD slot can't power a WiFi SD card reliably, so don't use an ez Share or a Toshiba FlashAir in it (4 below). Every other way works: a Sleep Bridge Lite (1, powered over USB-C, not by the slot), the machine's own Bluetooth (2 and 3), a local folder or the upload page (5).
1. Sleep Bridge Lite (recommended)
From the Sleep Bridge series, the Lite connects directly to the CPAP's SD slot and streams the data while the machine writes to the card, without interrupting the machine's own writes. It is powered over USB-C, not by the slot. The card stays in the machine, which keeps writing to it as if nothing were listening. The Lite pairs with hms-cpap on port 8894 for the live signal, and hms-cpap rebuilds the card's files from what it streams into a folder it reads like any card. The device and what it does are introduced in Introducing Sleep Bridge Lite.
Supported today: ResMed AirSense 10 and 11, AirCurve 10 and 11, and the BMC Luna G3, live. A Sefam S.Box card rebuilt by a Lite is read by its files as a Sefam card; that is not tested yet on a real machine. A Philips DreamStation 2 encrypts its card, so on a Sleep Bridge Lite it is read through the OSCAR you install yourself, live once OSCAR is paired; it is also read over Bluetooth (2 and 3 below). The brand work happens once, in the bridge, and hms-cpap reads a card as it always has. That is what makes hms-cpap brand agnostic, and what brings real-time capture of therapy to every machine the bridge supports.
Setting it up:
- hms-cpap listens for a bridge out of the box. In
config.jsonthat is"sleep_bridge": { "enabled": true, "port": 8894 }. In Docker publish-p 8894:8894; the Home Assistant add-on publishes it already. Only the stream answers on that port, never the web UI, and it has no login: keep it on your local network. - On the bridge's setup page (hold its button 10 seconds to reopen it),
choose My hms-cpap and type the IP address or hostname of this
computer, and the port: 8894 unless you changed
sleep_bridge.portin hms-cpap. The bridge tests the address before it keeps it. - Power the machine off and on once, outside therapy. The machine reads the card when it starts, and seeing that read is what lets the rebuild trust the card's layout. Until then hms-cpap holds what it receives and writes no file.
- The rebuilt card lands in
<data dir>/sleepbridge/<bridge>/, in the machine's own layout. The data dir is~/.hms-cpapnatively,/configin the Docker image (thecpap_configvolume) and/datain the add-on. Point a Local folder source at that folder (5 below), ResMed format.GET /api/sleepbridgelists every bridge with its folder (card_root), the machine it recognised (card_machine) and the format to read it with (card_format).
What you see: the night grows while you sleep. Each write reaches hms-cpap
as the machine makes it, and the dashboard follows on its sync interval. A
file is written only once every sector of it has been seen; a file that
stays held (listed in the bridge folder's batches/held.json) is one whose
first part was written while the bridge was not listening, before it was
powered or while hms-cpap was away longer than the bridge can hold. It is
never written with holes in it. The bridge keeps more than a night of writes
in its own memory while hms-cpap is unreachable and sends them when it
answers again.
With MQTT on, the mask and each event go to the broker as the rebuilt card shows them (see The night, live, on MQTT below).
The limit: the bridge forwards writes, so it only has what the machine wrote while it was powered and listening. Nothing already on the card from before is read through it. For the history already on the card, read the card once in a reader (5 below) and let the bridge carry on from there.
The receiver is new in this version. The wire protocol is in
docs/SLEEP_BRIDGE_LOCAL_STREAM.md; the
part that rebuilds files from the stream is a prebuilt component under its
own licence, linked only into builds made with -DBUILD_WITH_SLEEPBRIDGE=ON
(off by default from source; the published Docker image, the add-on, the
Raspberry Pi zip, the macOS app and the Windows installer are built with it,
from the asset pinned in
cmake/sleepbridge-pins.cmake; a Docker build of your own takes
--build-arg SLEEPBRIDGE=ON). A build without it still listens and refuses
every bridge, so a bridge's setup test fails rather than leaving it pointed at
a receiver that cannot use what it sends.
2. AirSense 11 or DreamStation 2 over Bluetooth from a computer
If your computer has Bluetooth and you own an AirSense 11 or an AirCurve 11, you do not need a bridge at all: hms-cpap connects to the machine directly and shows your nights live. The machine has its own Bluetooth, and hms-cpap becomes the device it talks to. The computer has to be in range of the machine. While a night streams, hms-cpap keeps the computer from going to sleep on its own (the screen can still turn off), and lets it sleep again when the night ends. A computer put to sleep by hand, or a closed laptop, drops the live night until it wakes; the day's summary is still read afterwards.
Which downloads have it:
| Download | Bluetooth |
|---|---|
macOS (the .dmg) |
Yes, through the Mac's own Bluetooth. The first time, macOS asks whether CpapDash may use Bluetooth: allow it (System Settings, Privacy & Security, Bluetooth, if you said no). If Bluetooth is off, switch it on: macOS does not let an app do that. |
| Windows (installer or zip) | Yes, Windows 10 or 11 with Bluetooth LE. If Bluetooth is off, hms-cpap switches it on. Use the Bluetooth adapter maker's own driver: on some adapters (a Realtek combo, for one) Windows' generic driver finds the device but never connects to it. No Windows pairing is involved. |
| Docker image, Home Assistant add-on | Yes, through the host's BlueZ: give the container the host's D-Bus, see the Docker section. |
| Raspberry Pi zip | Yes, through BlueZ. |
| Built from source on Linux | Only with -DBUILD_WITH_BLE=ON (needs libsdbus-c++). |
hms_cpap --ble-scan lists what this computer's Bluetooth can see and exits,
without connecting to anything: a quick way to check that the machine is in
range.
Turn it on in config.json:
"airsense11_ble": { "enabled": true, "address": "" }
address is optional: left empty, the first AirSense 11 the scan finds is
used. Then pair from the Devices page: on the AirSense 11's card, press
Pair AirSense 11, read the code off the machine's screen and type it within the
minute the machine allows. The machine holds one pairing at a time, so this
replaces the myAir app's pairing (and a bridge's); myAir's nightly reports
keep arriving over the machine's own modem. The pairing is kept in
<data dir>/as11.json, never in config.json.
What you get:
- The daily summary: the machine's own figures for each therapy day, the
same ones its
STR.edfcarries, pulled everyairsense11.pull_hours(6 by default) and stored as STR days, so the dashboard, trends and reports show them. - The live night: while therapy runs, the machine streams flow, mask
pressure, leak, respiratory rate, tidal volume, minute ventilation, snore
and flow limitation, and its own scored events. hms-cpap writes them as a
card under
<data dir>/as11/<machine serial>/:DATALOG/<night>/with BRP, PLD, EVE and CSL files (SAD when an oximeter rode along), the machine'sIdentification.json, and anSTR.edfbuilt from the summaries when the model's layout is known. Each file is a valid EDF at every moment, rewritten as the stream goes. When the night ends it goes through the same session import as a card's files and lands as its own session, with its metrics, files and the night's summary, whatever source the rest of the setup reads (none, a card, a WiFi card); nights found on disk at start-up that the database does not hold are imported then. A card read beside it wins the stretches it carries: a card session overlapping a Bluetooth one in time replaces it, and the Bluetooth session stays where the card has nothing. Pointing a Local folder source at the folder (5 below) is no longer needed, and still works for reading the night while it is being written.
The older summary-only path through a bridge's HTTP ("airsense11": { "enabled": true, "mule_url": "http://..." }) still works for a unit that
offers it; with airsense11_ble on it is not used.
Philips DreamStation 2. The same downloads read a DreamStation 2 over the
computer's own Bluetooth, after the night. Turn it on in Settings,
DreamStation 2 over Bluetooth (in config.json: "ds2_ble": { "enabled": true, "address": "" }), then pair it from the Devices page, with the
blower off and the machine close to the computer:
- The machine shows six digits, and so does the page; check they match and confirm on both within about 30 seconds. On a Mac, macOS shows the code in a window of its own instead: accept there and on the machine. Unlike the AirSense 11, this is a real Bluetooth pairing of the computer with the machine.
- The DreamStation keeps one Bluetooth pairing. Pairing hms-cpap replaces DreamMapper, or any other reader, on that machine: forget the machine in the old reader's Bluetooth settings (the phone's, for DreamMapper) first.
- Import nights from, on the Devices page, is the first day kept: the day of pairing unless you pick another. Sessions before it (a used machine's previous owner) are skipped and never stored.
When it is read is your choice, in Settings: once a day at a time you pick (11:00 by default) or only when I ask (Read now on the Devices page). In both, another source here saying the night ended (a Sleep Bridge, a Mule & Miner, the AirSense 11 over Bluetooth, the O2 ring) also starts a read. Nothing is read while a mask is on, and the machine never hands over a session still being recorded. Each read brings the sessions closed since the last one and imports them like a card's nights. These nights are not sent to SleepHQ.
3. A Mule & Miner in Bluetooth mode (AirSense 11 or DreamStation 2)
The Mule & Miner now transmits to hms-cpap locally, so if your desktop PC is
too far from the CPAP for its own Bluetooth, the Mule & Miner bridges that
gap. The CpapDash dual-radio unit holds the machine's Bluetooth pairing
instead of this computer, and sends the night here instead of to the cloud.
On the unit, set the hms-cpap address to this computer's IP address or
hostname (nothing else: no ws://, no port, no path) and the port, 8894
unless you changed sleep_bridge.port; it connects to
ws://<host>:<port>/mule/v1/device, the same port the Sleep Bridge receiver
listens on, so sleep_bridge.enabled must stay on.
It feeds the same writer as 2 above: the same files under
<data dir>/as11/<machine serial>/, the same live night, imported as a
session the same way when it ends. Every block and every event also wakes
hms-cpap's sync at once, and with MQTT on, each event and each therapy start
and end goes to the broker as it arrives (see
The night, live, on MQTT below), for
automations during the night. When the night ends the unit is asked for the
machine's identification, summary and settings history; the summary is what
builds the folder's STR.edf. GET /api/mule lists the units seen. The
protocol is in docs/MULE_LOCAL_STREAM.md.
A unit that reads a WiFi SD card (not Bluetooth) cannot stream to hms-cpap. If one is pointed here anyway, its card on the Devices page says so and offers only Switch to the CpapDash cloud, which sends it back to the cloud; nothing of its nights is taken here.
A DreamStation 2 through a Mule & Miner. A unit whose firmware supports
the DreamStation 2 reads one over its own Bluetooth instead of an AirSense
11, set up the same way (the hms-cpap address and port on the unit). Use
miner firmware 6.0.2 or newer: earlier miners stop after the summaries and
bring no events. On the
unit's card on the Devices page, turn on DreamStation 2 Bluetooth
(the miner restarts with it), then Pair DreamStation 2: the unit asks the
machine to pair and the page shows the six digits it holds; check they match
the machine's, press Codes match and confirm on the machine. The same
notes as in 2 above apply: blower off, one pairing per machine, and nights
kept from the import day on. It is read on the same Settings choice as in 2
(once a day at your time, or only when asked, and when another source says
the night ended), its nights are imported the same way, and beside them the
unit's reads leave the machine's files in a card's layout under
<data dir>/ds2card/<serial>/P-SERIES/, which OSCAR 2.1.1 imports like a
card.
4. WiFi SD cards (ez Share and Toshiba FlashAir)
A WiFi SD card sits in the CPAP's SD slot in place of the plain card and
serves the card's files over WiFi; hms-cpap polls it and copies what is new
into an archive_dir, which both cards need. The ez Share was the original
path and the FlashAir came after it. Neither is the recommended path any
more: the card's WiFi runs on the machine's slot power through the night,
and some machines cannot hold it (the AirSense 11 REF 39517 above), which
shows up as brownouts and card errors; and a card reader only ever sees what
the card already holds, after the card holds it. A Sleep Bridge Lite leaves
the card alone and sees each write as it is made. If your WiFi card works
today, nothing here stops working.
ez Share. The card makes its own network, so you need a bridge such as
hms-mm (Mule & Miner) to put it on
your LAN; the wizard can scan for one. To set a bridge up, the
hms-mm web flasher flashes both of
its boards from Chrome and takes your WiFi details on the same page, nothing
to install. In config.json: "transport": "ezshare", "ezshare_url": "http://192.168.4.1", "ezshare_range": true (set it false for a card that
does not resume downloads), and an archive_dir. Works with a ResMed card.
A BMC Luna card ("format": "bmc") and a Sefam S.Box card ("format": "sefam") in an ez Share are not tested yet on a real machine: read those
cards from a local folder or the upload page (5 below).
Some ez Share cards (firmware LZ1001EDPG:4.4.0) answer directory
listings with their welcome page. For ResMed cards only, hms-cpap can
find date folders from STR.edf, discover files through their FAT 8.3
aliases and read them in 8 KiB pieces. This has been tested on an
AirSense 11 after therapy, with direct HTTP access to the card; it has
not been tested through a Mule & Miner or while therapy is running.
These cards are slow, about 1 KB/s, so the first sync of a full card
can take hours.
Toshiba FlashAir. The card joins your home WiFi itself, so no bridge is
needed. Set it to join your network (APPMODE=5 in its SD_WLAN/CONFIG)
and pick FlashAir in the wizard; it is found as http://flashair.local, or
give its address. In config.json: "transport": "flashair",
"flashair_url": "http://flashair.local", and an archive_dir. Tested on a
FlashAir W-02 in an AirSense 10, read live through a full night. A BMC Luna
card ("format": "bmc") and a Sefam S.Box card ("format": "sefam") in a
FlashAir are read the way an ez Share reads them, through a copy of the card
in archive_dir; neither is tested yet on a real machine.
5. Local folder and the upload page
- Local folder: point the wizard at the SD card root (the folder that
holds both
STR.edfandDATALOG/), on a USB reader, a NAS share, or any mount, and say which machine wrote it. Inconfig.json:"transport": "local","local_dir", and"format":resmed,lowenstein(a Prisma tree, a serial folder with noDATALOG),sefam,bmcfor a Luna, orphilipsfor a DreamStation card (a DreamStation 2 encrypts its card: hms-cpap does not decrypt it and reads it through your own OSCAR, set in"oscar": {"program", "data_dir", "profile"}, see above). A path one level too deep is refused rather than guessed. This is also how the folders written by a Sleep Bridge Lite (1) and the AirSense 11 streams (2 and 3) are read. - Upload page: zip the card and drop it in the browser. A ResMed, Sefam, Löwenstein or Luna card is recognised by its files, and every night not yet stored is imported. No shared network needed.
The night, live, on MQTT
With MQTT on, every source above says the mask on the same topics, and Home Assistant discovers the same entities on the hms-cpap device:
| Entity | Topic | What it holds |
|---|---|---|
Mask (binary_sensor, Running / Not running) |
cpap/<device_id>/realtime/mask |
ON / OFF, retained |
| its attributes | cpap/<device_id>/realtime/mask_changed |
the change that set it, retained: state, source, source_id, session, occurred_at, detected_at, delay_s |
Live events (sensor) |
cpap/<device_id>/realtime/live_events |
events since the mask went on: {"total":3,"OA":1,"H":2}, retained; the per-type counts are its attributes |
| (no entity) | cpap/<device_id>/realtime/event |
one respiratory event as it lands, not retained |
occurred_at is when the mask really went on or off, on the machine's clock
read on the real one, and detected_at is when hms-cpap saw it (both UTC,
ISO 8601 with Z, as the CpapDash cloud's mask.on and mask.off carry
them); delay_s is the difference, so an automation can tell a live change
from a late one. A mask goes on at its session's start and off at the end of
its last record. The mask is on while any source says so.
Source (source) |
Mask on | Mask off | Events | Typical delay_s |
|---|---|---|---|---|
Sleep Bridge Lite (sleep_bridge) |
the first therapy write streamed | the STR the machine writes at mask-off, or 5 min with no therapy write while the bridge is still delivering; a bridge gone completely silent is waited on for 15 min, since a link that stalls and delivers late looks the same | yes | on: up to about a minute (the machine's first write); off: seconds after the STR, about 5 min on the fallback, 15 on a silent link |
Mule & Miner, AirSense 11 Bluetooth mode (mule_ble) |
the stream starts | the stream ends (the end of its last block) | yes | seconds |
AirSense 11 over this computer's Bluetooth (as11_ble) |
the stream starts | the stream ends | yes | seconds |
ez Share (ezshare), FlashAir (flashair), local folder (local) |
a burst finds the session's BRP grown | the BRP has not grown for 135 s | no | about 2 minutes, up to a burst interval more: a change needs the next burst to show |
A local folder that a Sleep Bridge or an AirSense 11 stream writes is reported by that source, live, not again as a card. A Löwenstein, Sefam or Luna card has no BRP, so it has no live mask.
After a restart of hms-cpap, a source that sees the mask says it again (a
Mule & Miner on its first state, a Sleep Bridge on its next therapy write); if
no source says anything for 5 minutes, OFF is published once with source
startup, so a retained ON from a night that ended while hms-cpap was away
does not stay.
Kept for the automations already built on them: the Mule & Miner's own
cpap/<device_id>/live/* topics (therapy, therapy_changed, event,
last_event, event_count, ahi) and their entities (Live therapy,
Live event count, Live AHI, Live last event), as
docs/MULE_LOCAL_STREAM.md describes them. New
automations should use the table above, which every source fills.
Therapy active over MQTT
For "is therapy running right now", use the Mask entity. With a Sleep
Bridge Lite it flips within about a minute of the mask going on (the
machine's first therapy write) and within seconds of it coming off (the STR
the machine writes at mask-off); a card read over WiFi or from a folder is
about two minutes late, and says so in delay_s.
cpap/<device_id>/realtime/mask ON
cpap/<device_id>/realtime/mask_changed {"state":"on","source":"sleep_bridge",
"source_id":"TAP-S3-00000123",
"session":"20261105_010913",
"occurred_at":"2026-11-05T06:09:13Z",
"detected_at":"2026-11-05T06:10:02Z",
"delay_s":49}
Both are retained, so Home Assistant has the state and its attributes after a restart of either side. A Home Assistant automation:
automation:
- alias: "CPAP therapy started"
triggers:
- trigger: state
entity_id: binary_sensor.cpapdash_mask # the Mask entity on your hms-cpap device
to: "on"
actions:
- action: light.turn_off
target:
entity_id: light.bedroom
Or straight off the broker: mosquitto_sub -v -t 'cpap/+/realtime/mask'.
RT session_active and RT session_status
(cpap/<device_id>/realtime/session_active, .../session_status) are the
slower "is the session over" signal: ON / in_progress while the session's
files grow, OFF / completed once they have stopped. With a source that
streams the night (Sleep Bridge, Mule & Miner) that is the first burst after
the mask comes off on the stream and the files stop, a minute or two. An
AirSense 11 or AirCurve 11 read over this computer's Bluetooth says ON when
its stream starts and OFF when it ends. With a card read over WiFi or from a folder it is when
the night is over: an hour with no growth, ResMed's own rule for a closed
night, so a mask back on within it is the same night.
The times in these payloads are only as right as the zone hms-cpap runs in:
the machine keeps local time, so set TZ on a Docker container (see
Install).
Everything else (config keys, CLI flags, MQTT sensor list, myAir setup, architecture, development, cross-compiling) is in docs/REFERENCE.md.
How it is built
The architecture/ folder maps the code:
- architecture/db.md: every table on SQLite, MySQL and PostgreSQL, how they are keyed and related, who writes and reads each one, and the time rules every date follows.
- architecture/layers.md: the layers of the app (entities, the database layer, services, the web query layer, controllers, the frontend) and how a web request and a collection burst travel through them.
Disclaimers
- Not a medical device. It does not diagnose anything and it is not a monitoring or alarm system. Never adjust your therapy based on this software. DISCLAIMER.md
- The data can be wrong. Parsers are reverse-engineered from undocumented formats and collection can fail silently. Cross-check with your clinician or the manufacturer's own tools.
- No authentication. The web UI has no login. Keep it on your LAN; do not expose it to the internet.
- Privacy. There is no telemetry and nothing phones home. The only outbound integrations are SleepHQ, CpapDash sync, myAir, and LLM summaries, all off by default and each one you enable yourself. PRIVACY.md
- Independence. Not affiliated with or endorsed by ResMed, Philips, Löwenstein Medical, Sefam, BMC, React Health, SleepHQ, or any other company named here. Trademarks belong to their owners. No OSCAR source was copied or derived from; it was consulted only to understand file formats. NOTICE
- License. MIT. Use it, modify it, sell it; keep the notice. LICENSE · TERMS.md
- Sleep Bridge component. The part that rebuilds card files from a Sleep
Bridge's stream is not MIT source: it is a prebuilt binary under its own
licence, LICENSE-sleepbridge, linked only into builds
made with
BUILD_WITH_SLEEPBRIDGE=ON. The stream itself is documented in docs/SLEEP_BRIDGE_LOCAL_STREAM.md.
Contributing & support
Fork, branch, add tests, make sure ./tests/run_tests passes, open a PR. See
docs/CONTRIBUTING.md.
If this project is useful to you, consider buying me a coffee or starring the repo.
Ähnliche Projekte entdecken
Wird geladen…