Small Python client for Tasmota HTTP command API
Project description
tasmota-http
A Python library for the local Tasmota HTTP command API.
The library provides:
- a single HTTP client for
http://<device>/cm?cmnd=...; - optional credential support via URL query (
user,password); - convenience methods for common operations (
Status,Power,Backlog); - a unified transport and command error layer.
Contents
- Quick Start
- Authentication
- Supported Methods
- Error Handling
- API Documentation
- Usage Examples
- Build and Release
- Development and Tests
Quick Start
1) Install
cd /mnt/NetworkBackupShare/api_doc/tasmota-http
python3 -m pip install -e .
2) Basic usage
from tasmota_http import TasmotaClient, TasmotaCommandError, TasmotaTransportError
client = TasmotaClient("192.168.33.50")
try:
status = client.status(0)
before = client.power_get()
client.power_set(True)
after = client.power_get()
print("status keys:", list(status.keys()) if isinstance(status, dict) else status)
print("before:", before)
print("after:", after)
except TasmotaCommandError as e:
print(f"Command error: {e}")
except TasmotaTransportError as e:
print(f"Transport error: {e}")
Authentication
If your web commands require credentials:
from tasmota_http import TasmotaClient
client = TasmotaClient(
"192.168.33.50",
username="admin",
password="secret",
)
Supported Methods (v1)
Generic methods
send_command(command)
Convenience methods
backlog(commands)->Backlog ...status(code=0)->Status <code>power_get(channel=1)->Power/Power<x>power_set(on, channel=1)->Power ON|OFFpower_toggle(channel=1)->Power TOGGLE
Error Handling
TasmotaTransportError- network errors;
- HTTP errors.
TasmotaCommandError- invalid command inputs before request (empty command, bad channel, etc.).
API Documentation
- Detailed class and method reference: docs/API.md
- Ready-to-run usage scenarios: docs/EXAMPLES.md
- Build and release instructions (uv): docs/BUILD.md
Development and Tests
Run tests:
PYTHONPATH=src python3 -m unittest discover -s tests -v
Sources (local docs snapshot)
tasmota.github.io/docs/Commands/index.htmltasmota.github.io/docs/MQTT/index.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tasmota_http-0.1.0.tar.gz
(4.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tasmota_http-0.1.0.tar.gz.
File metadata
- Download URL: tasmota_http-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68deb2f22ff8827613a4f4a18cfba5d0d27be845871e0bf70c5a7537b9af0115
|
|
| MD5 |
48b02b7c56040b7df68dc4567774ff69
|
|
| BLAKE2b-256 |
8e81a9f06320c3c02d46d5f51ea0eafe8c6569031e6e79d2a3a612ec4103a9a2
|
File details
Details for the file tasmota_http-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tasmota_http-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa7f908eda732e4bc59bc8ec1cf30d48e1cfbd608086db75716ce549ad9dfeb
|
|
| MD5 |
a2e20434053fe3d40f88a0c0dd13706f
|
|
| BLAKE2b-256 |
3c1a9d0298981361e8dce6bef3d3eb7afd0a1f72dc8c31c593c55ec874eff879
|