Skip to main content

Python app-server framework for the io7 IoT platform

Project description

io7app

A small, intuitive Python framework for writing app servers on the io7 IoT platform.

You decorate Python functions with the device events they react to and the schedules they fire on. The framework owns the MQTT connection, topic routing, JSON envelope handling, scheduling, and dynamic register/unregister. Your code stays focused on business logic.

The io7 platform — where this library fits

┌──────────┐                  ┌──────────┐                  ┌─────────────────┐
│  Devices │ ── events ──▶    │  Broker  │ ── events ──▶    │       App       │
│ (sensors,│                  │(Mosquitto)│                  │  (this library, │
│actuators)│ ◀── commands ──  │          │ ◀── commands ──  │   one process)  │
└──────────┘                  └──────────┘                  └─────────────────┘
   (many)                                                        (one)

io7 separates the world into two roles. Devices publish events (sensor readings, status changes) and receive commands (actuation requests). Apps subscribe to events from any device and publish commands to any device — they are where the IoT business logic lives ("if temperature drops, turn the valve on", "when the switch flips, mirror it on the lamp").

This library implements only the App side. Device firmware lives in the io7 device libraries (ESP32, ESP8266, MicroPython).

Install

pip install io7app
# Optional, only if you use @inject(cron=...)
pip install croniter

Requires Python ≥ 3.10. Talks to any standard MQTT broker (Mosquitto, EMQX, HiveMQ, the io7 platform itself).

Configure

Drop a .env next to your script (copy from .env.example):

IO7_SERVER=iot201.ddns.net
IO7_APP_ID=app3
IO7_TOKEN=app3

That's the minimum. TLS, port overrides, and log levels are documented in the user guide.

Status

  • Version 0.1.0
  • ~640 lines of Python across three small modules (router, scheduler, app)
  • 71 tests, all green
  • One dependency: paho-mqtt. Plus python-dotenv for config and optionally croniter for cron schedules.

Where to go next

  • USER_GUIDE.md — write your first app, decorator reference, scheduling, dynamic register/unregister, debug logging. Every claim in the guide is exercised by a test.
  • examples/ — five runnable apps: switch/lamp, thermostat/valve, lux auto-lamp, scheduled inject, wildcard tracing.
  • docs/superpowers/specs/ — design document.
  • docs/superpowers/plans/ — implementation plan.

Develop

git clone <this-repo>
cd io7app
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

Design principles

  • Small. Three modules, one class, four decorators.
  • Intuitive. A working app is 3-5 lines of business logic.
  • Honest. No magic — handler signatures are inspected, not assumed; dropped messages are silent only when the spec says so; warnings spell out exactly what was deduplicated and why.
  • Optimal where it counts. Static topics dispatch in O(1); wildcards compile to a regex once; overlapping decorators are consolidated at registration time so handlers never double-fire.

License

MIT — see LICENSE. Same as the rest of the io7lab packages.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

io7app-0.1.0.tar.gz (46.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

io7app-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file io7app-0.1.0.tar.gz.

File metadata

  • Download URL: io7app-0.1.0.tar.gz
  • Upload date:
  • Size: 46.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for io7app-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b53de5e471e200161aecce9071125aebd0c4dfa5d6dde30eb92e93212c0e68bf
MD5 2bce8ecad126ab59ed53da5c71c761c7
BLAKE2b-256 8eb3466e762c30942f32c931926dfe6ad0269cb1a0f9c7ce8651f945d2199ce4

See more details on using hashes here.

File details

Details for the file io7app-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: io7app-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for io7app-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc9f5fa270d3adeff9ed3d7355bcf4687a2451d808913a14408ad7831930b2c
MD5 5bea0823b3a64612c17d6b7e5637bed1
BLAKE2b-256 0cc0dd1be9e6c2161a123840fa012a8684658e3f35ffebc027ba4f9fa839d125

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page