Skip to main content

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|OFF
  • power_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

Development and Tests

Run tests:

PYTHONPATH=src python3 -m unittest discover -s tests -v

Sources (local docs snapshot)

  • tasmota.github.io/docs/Commands/index.html
  • tasmota.github.io/docs/MQTT/index.html

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

tasmota_http-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

tasmota_http-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

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

Hashes for tasmota_http-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68deb2f22ff8827613a4f4a18cfba5d0d27be845871e0bf70c5a7537b9af0115
MD5 48b02b7c56040b7df68dc4567774ff69
BLAKE2b-256 8e81a9f06320c3c02d46d5f51ea0eafe8c6569031e6e79d2a3a612ec4103a9a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tasmota_http-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1aa7f908eda732e4bc59bc8ec1cf30d48e1cfbd608086db75716ce549ad9dfeb
MD5 a2e20434053fe3d40f88a0c0dd13706f
BLAKE2b-256 3c1a9d0298981361e8dce6bef3d3eb7afd0a1f72dc8c31c593c55ec874eff879

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