轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像
交易
充值流量¥7起我的订单
文档
工具
提交工单页面收录
mqttcommander

xomoxcc/mqttcommander

xomoxcc

Toolkit for discovering, monitoring, and controlling Tasmota devices via MQTT with CLI utilities

下载次数: 0状态:社区镜像维护者:xomoxcc仓库类型:镜像最近更新:4 个月前
让 AI 帮你使用轩辕镜像? · 展开查看说明 · 点击收起说明

如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。

只需在 AI 对话中先发送下面这句话即可:

请先完整阅读并严格遵守以下文档中的全部规则与要求:

https://xuanyuan.cloud/agents.md

在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。

查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。

镜像简介
下载命令
镜像标签列表与下载命令
轩辕镜像,不浪费每一次拉取。
点击查看

!https://github.com/vroomfondel/mqttcommander/actions/workflows/mypynpytests.yml/badge.svg https://github.com/vroomfondel/mqttcommander/actions/workflows/buildmultiarchandpush.yml/badge.svg](https://github.com/vroomfondel/mqttcommander/actions/workflows/buildmultiarchandpush.yml) !https://img.shields.io/endpoint?logo=github&url=https://gist.githubusercontent.com/vroomfondel/65da30603d04548c80d1e67042b60a6f/raw/mqttcommander_clone_count.json ![PyPI Downloads]([***]

https://github.com/vroomfondel/mqttcommander/raw/main/Gemini_Generated_Image_mqttcommander_wjpr8gwjpr8gwjpr_250x250.png](https://github.com/vroomfondel/mqttcommander)

MQTTCommander

Convenience tools for discovering and commanding Tasmota devices over MQTT, plus a small CLI and a ready-to-use Docker image. This project now depends on the external library mqttstuff for the generic MQTT client/wrapper utilities — the mqttstuff source is no longer embedded in this repo and is pulled via the package manager.

Key capabilities:

  • Connecting/subscribing and publishing via the mqttstuff wrapper

  • Reading “last/most recent” messages with timeout-based collection

  • Inspecting and commanding Tasmota devices via their MQTT topics

  • Pydantic-based configuration (YAML + environment overrides)

  • Developer helpers for JSON pretty-printing, deep updates, and logging configuration

  • This repository: mqttcommander

  • External dependency: mqttstuff (https://github.com/vroomfondel/mqttstuff)

Overview

MQTTCommander builds on top of paho-mqtt through the external mqttstuff library to simplify common patterns:

  • A mqttstuff.mosquittomqttwrapper.MosquittoClientWrapper to configure, connect, subscribe, and publish with minimal boilerplate
  • A mqttstuff.mosquittomqttwrapper.MQTTLastDataReader utility to retrieve the most recent messages quickly
  • A mqttcommander.tasmotacommander.MqttCommander toolkit to discover Tasmota devices from retained topics and interact with them in bulk
  • Pydantic settings in config.py to load credentials and broker details from config.yaml/config.local.yaml and/or environment

The project also includes a Dockerfile for a batteries-included container image useful for testing and running these tools in a consistent environment.

Quick Start

Simple publish and subscribe using the wrapper:

python
from mqttstuff import MosquittoClientWrapper

client = MosquittoClientWrapper(
    host="localhost", port=1883, username="user", password="pass",
    topics=["test/topic"],
)

def on_any_message(msg, userdata):
    # msg is an instance of MWMqttMessage with convenient fields
    print(msg.topic, msg.value)

client.set_on_msg_callback(on_any_message, rettype="valuemsg")
client.connect_and_start_loop_forever()

# elsewhere or in another process
client.publish_one("test/topic", {"hello": "world"}, retain=False)

Read last retained or recent messages with a timeout:

python
from mqttstuff import MQTTLastDataReader

data = MQTTLastDataReader.get_most_recent_data_with_timeout(
    host="localhost", port=1883, username="user", password="pass",
    topics=["tele/+/STATE", "stat/+/STATUS"],
    retained="only",  # "yes" | "no" | "only"
    rettype="str_raw", # or "json", "valuemsg", "str", "int", "float"
)
print(data)

Configuration

Configuration is defined with Pydantic Settings in config.py and loaded from:

  1. Environment variables
  2. config.local.yaml (if present)
  3. config.yaml

You can override paths with environment variables:

  • MQTTCOMMANDER_CONFIG_DIR_PATH – base config dir
  • MQTTCOMMANDER_CONFIG_PATH – path to main YAML config
  • MQTTCOMMANDER_CONFIG_LOCAL_PATH – path to local override YAML

The Mqtt section is expected to contain common fields like host, port, username, password, and optional topic lists. See the file headers in config.py for details.

Python Modules

Each Python module provided by this repository is documented here with a focused explanation of its purpose and usage.

Package: mqttcommander

Tools to discover and command Tasmota devices using their MQTT topics.

Highlights:

  • Data models for timers, timezone/DST config, device config and sensors
  • MqttCommander to collect retained messages across topics, filter noisy subtrees, and start processing loops
  • Discovery helpers:
    • get_all_tasmota_devices_from_retained(...)
    • filter_online_tasmotas_from_retained(...)
    • update_online_tasmotas(...)
  • Command helpers to send one or many commands to all online devices:
    • send_cmds_to_online_tasmotas(tasmotas, to_be_used_commands=[...], values_to_send=[...])
  • Firmware management:
    • ensure_freshest_firmware(online_tasmotas, dry_run=False)
  • Timezone utilities to ensure consistent device settings:
    • ensure_correct_timezone_settings_for_tasmotas(online_tasmotas)
  • JSON utilities and pretty-printers for review and persistence:
    • write_tasmota_devices_file(...)
    • read_tasmotas_from_latest_file(...)

Example – list online devices and send a command:

python
from mqttcommander import MqttCommander

comm = MqttCommander(host="localhost", port=1883, username="user", password="pass")
all_devs = comm.get_all_tasmota_devices_from_retained(topics=["tele/+/STATE"], noisy=False)
online = comm.filter_online_tasmotas_from_retained(all_devs)
comm.send_cmds_to_online_tasmotas(online, to_be_used_commands=["Power"], values_to_send=[["Toggle"]])

Module: config

  • Centralized configuration and Loguru logging setup
  • Uses pydantic-settings to read from environment and YAML
  • Timezone helpers and constants (e.g., TZBERLIN)
  • Environment variables LOGURU_LEVEL, MQTTCOMMANDER_CONFIG_* are respected

Typical usage:

python
from config import Settings

settings = Settings()  # loads from env + config.local.yaml + config.yaml
print(settings.MQTT.host, settings.MQTT.port)

Module: Helper

Small utilities used across the project:

  • ComplexEncoder for JSON serialization of complex types (UUID, datetimes, dict/list pretty rendering)
  • print_pretty_dict_json, get_pretty_dict_json, get_pretty_dict_json_no_sort
  • update_deep(base, u) for deep dict/list merge/update
  • get_exception_tb_as_string(exc) for converting exception tracebacks to strings
  • get_loguru_logger_info() to introspect Loguru handlers and filters

Docker

The repository contains a ready-to-use Dockerfile at the repository root designed for local development and CI usage.

What the Docker image includes

  • Base: python:${python_version}-${debian_version} (defaults 3.14-trixie)
  • Useful packages: htop, procps, iputils-ping, locales, vim, tini
  • Python dependencies from requirements.txt and requirements-dev.txt
  • Source code copied into /app and PYTHONPATH=/app
  • Loguru-friendly environment with tini as entrypoint

Build arguments

  • python_version – default 3.14
  • debian_version – default trixie
  • UID, GID, UNAME – user configuration in the image (defaults: 1234/1234/pythonuser)
  • TARGETOS, TARGETARCH, TARGETPLATFORM – auto-populated by BuildKit/buildx for multi-arch
  • gh_ref, gh_sha, buildtime – injected into environment variables (GITHUB_REF, GITHUB_SHA, BUILDTIME)

Building the image

Basic build:

bash
docker build -t xomoxcc/mqttcommander:latest .

Pass custom Python/Debian versions:

bash
docker build \
  --build-arg python_version=3.12 \
  --build-arg debian_version=bookworm \
  -t xomoxcc/mqttcommander:py312 .

Embed source metadata (useful in CI):

bash
docker build \
  --build-arg gh_ref="${GITHUB_REF}" \
  --build-arg gh_sha="${GITHUB_SHA}" \
  --build-arg buildtime="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
  -t xomoxcc/mqttcommander:with-meta .

Multi-architecture build with buildx (example for amd64 and arm64):

bash
docker buildx build \
  --platform linux/amd64,linux/arm64 \
  -t ghcr.io/youruser/xomoxcc-mqttcommander:latest \
  --push .

Note: This repository already provides a docker-config/ buildx context. You can reuse your existing builder or create a new one:

bash
docker buildx create --name mbuilder --use || true
docker buildx inspect --bootstrap

Running the image

The image uses tini as entrypoint and runs the application by default via:

ENTRYPOINT ["tini", "--", "python", "main.py"]

Implications:

  • By default, the container starts python main.py inside /app.
  • To run a shell or the CLI directly instead, override the entrypoint with --entrypoint.
  • Environment variables like MQTTCOMMANDER_CONFIG_DIR_PATH can be used to point the app to your configs.
  • main.py is a wrapper to inject values read from config.yaml/config.local.yaml/ENV (in that order; "the latter overrides values from the earlier") into the call to mqttcommander.cli:main

Examples:

bash
# Run the default app (python main.py via tini) with your config
docker run --rm -it \
  -e LOGURU_LEVEL=INFO \
  -e MQTTCOMMANDER_CONFIG_DIR_PATH=/app \
  -v "$(pwd)/config.local.yaml:/app/config.local.yaml:ro" \
  xomoxcc/mqttcommander:latest

# Start a shell for inspection (override entrypoint)
docker run --rm -it \
  -e LOGURU_LEVEL=DEBUG \
  -e MQTTCOMMANDER_CONFIG_DIR_PATH=/app \
  -v "$(pwd)/config.yaml:/app/config.yaml:ro" \
  --entrypoint tini xomoxcc/mqttcommander:latest -- \
  /bin/bash

# Run the mqttcommander CLI directly
docker run --rm -it \
  -e LOGURU_LEVEL=DEBUG \
  --entrypoint tini xomoxcc/mqttcommander:latest -- \
  mqttcommander --host broker --port 1883 --username user --password pass list-online

# Run a Python one-liner using the mqttstuff wrapper (installed as dependency)
docker run --rm -it \
  --entrypoint tini xomoxcc/mqttcommander:latest -- \
  python -c "from mqttstuff import MQTTLastDataReader as R; print(R.get_most_recent_data_with_timeout('broker',1883,'user','pass',['tele/+/STATE'], retained='only'))"

Recommendation: You should always try to run python(especially python, but imho all other processes as well) through an entrypoint via tini to ensure proper signal handling (STOP/KILL/TERM/INT) and process reaping for/inside the conainer.

bash
# Run the default app (python main.py via tini) with your config
docker run --rm -it \
  --network=host \
  -e LOGURU_LEVEL=DEBUG \  
  -v "$(pwd)/config.local.yaml:/app/config.local.yaml:ro" \  
  --entrypoint tini xomoxcc/mqttcommander:latest -- \
  python main.py list-retained-msgs --grace-s 10

Why Docker here is useful

  • Ensures consistent Python/dependency versions across dev machines and CI
  • Provides a preconfigured environment for quick experiments against an MQTT broker
  • Makes multi-arch builds straightforward with buildx

Development

Helpful Makefile targets:

  • make help – list available targets with short descriptions
  • make install – create virtualenv and install development requirements
  • make venv – ensure .venv exists and dev requirements are installed
  • make tests – run pytest
  • make lint – run Black code formatter
  • make isort – fix and check import order
  • make tcheck – run mypy type checks over *.py, scripts/, and mqttcommander/
  • make commit-checks – run pre-commit hooks on all files
  • make prepare – run tests and commit-checks (useful before committing/PRs)
  • make pypibuild – build sdist and wheel with Hatch into dist/
  • make pypipush – publish built artifacts with Hatch (configure credentials first)
  • make build – build the Docker image via ./build.sh
  • make dstart – start ephemeral container (host network), mapping config.local.yaml into /app

TasmotaCommander usage examples

Via CLI

The image and PyPI package install a console script mqttcommander. Common actions:

bash
# 1) List discovered Tasmota devices from retained discovery topics
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  list-tasmotas

# 2) Send a command to all online devices (e.g., toggle power)
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  send-cmd --command Power --value Toggle

# 3) List only online devices
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  list-online

# 4) Upgrade online devices if newer firmware is available (via OtaURL)
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  upgrade-online --dry-run

# 5) Trigger LWT Online for all currently offline devices (using Publish2)
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  trigger-lwt-send

# Bonus) Show how many retained messages match default topics and print a few
#        Optional: increase receive window and enable verbose output
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  list-retained-msgs

# with options:
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  list-retained-msgs --grace-s 10 --noisy

# Bonus) Load previously saved device list (if present) and show count
#        Optional: specify custom snapshot directory and timezone
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  readfromfile

# with options:
mqttcommander \
  --host broker --port 1883 --username user --password pass \
  readfromfile --tasmota-json-dir /path/to/snapshots --timezone Europe/Berlin

When running inside Docker, use --entrypoint mqttcommander as shown above, and pass the same flags.

Via Python API

Two additional examples that build on the MqttCommander API:

python
# Example A: Read retained discovery/state data and print topic summary
from mqttcommander import MqttCommander

comm = MqttCommander(host="localhost", port=1883, username="user", password="pass")
msgs = comm.get_all_retained_msgs(topics=["tasmota/discovery/#", "tele/+/STATE"], noisy=False, rettype="json")
if msgs:
  print(f"Collected {len(msgs)} retained messages")
  for m in msgs[:5]:
    print(m.topic)

# Example B: Ensure timezone settings are correct on all online devices
from mqttcommander import MqttCommander

comm = MqttCommander(host="localhost", port=1883, username="user", password="pass")
all_devs = comm.get_all_tasmota_devices_from_retained(noisy=False)
online = comm.filter_online_tasmotas_from_retained(all_devs)
comm.ensure_correct_timezone_settings_for_tasmotas(online)

# Example C: Upgrade firmware on all online devices (dry run)
comm.ensure_freshest_firmware(online, dry_run=True)

Testing

Tests live under tests/. Run all tests with:

bash
pytest -q

License

This project is licensed under the LGPL where applicable/possible — see LICENSE.md. Some files/parts may be governed by other licenses and/or licensors, such as MIT | GPL | LGPL. Please also check file headers/comments.

Acknowledgments

See inline comments in the codebase for inspirations and references.

⚠️ Disclaimer

This is a development/experimental project. For production use, review security settings, customize configurations, and test thoroughly in your environment. Provided "as is" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Use at your own risk.

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 mqttcommander 镜像标签

docker pull docker.xuanyuan.run/xomoxcc/mqttcommander:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull xomoxcc/mqttcommander:<标签>

轩辕镜像配置手册

按平台快速找到配置文档

一键安装

一键安装 Docker

Linux Docker 一键安装

AI

用 AI 使用轩辕镜像

agents.md · AI 对话 · 提示词

Docker

登录仓库拉取

登录认证 · 私有仓库

专属域名拉取

免登录 · 高速拉取

Linux

Docker 镜像配置

Windows / Mac

Docker Desktop 配置

MacOS OrbStack

OrbStack 容器

Apple Container

macOS 原生容器

Docker Compose

Compose 项目配置

NAS

群晖

Synology 配置

飞牛

fnOS 镜像配置

绿联

绿联 NAS

威联通

QNAP 配置

极空间

极空间 NAS

Unraid

Unraid NAS

企业仓库

其他仓库

ghcr · Quay · nvcr

Harbor 镜像源

Proxy Repository 对接

Portainer 镜像源

Registries 配置

Nexus 镜像源

Docker Proxy 缓存

开发工具

Dev Containers

VS Code 开发容器

Podman

Podman 配置指南

Singularity / Apptainer

HPC 科学计算容器

Kubernetes

K8s Containerd

Kubernetes · Containerd

K3s

轻量级集群

面板 / 网络

爱快路由

爱快 4.0 · iKuai 镜像加速

宝塔面板

一键配置镜像源

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

功能

版本功能对比

功能对比 · 版本选择

支持的镜像仓库

Docker Hub · GCR · GHCR

专属域名用法

专属域名 · 开启停用 · 多仓库

新手拉取配置

登录 · 专属域名 · 配置

docker search 限制

专属域名 · Hub 搜索

不支持 push

仅支持 pull · 不支持

拉取速度原因

带宽 · 缓存 · 冷热镜像

错误码

402 与流量用尽

402 · 流量包 · 充值

401 认证失败

401 · docker login

manifest unknown

标签错误 · 镜像不存在

410 Gone 排查

410 · Docker 升级

429 限流

免费版 · 专业版 · 企业版 · 请求频率

其他报错

DNS 超时

DNS 解析 · 网络超时

TLS 证书失败

no matching manifest(架构)

账号

失败是否计费

manifest · blob · 计费

申请开发票(企业 / 个人)

企业 · 个人 · 工单

修改登录密码

网站 · 仓库 · 重置

注销账户

工单 · 数据 · 注销

原理

mirrors 不生效

daemon.json · 重启

去掉域名前缀

docker tag · 重命名

指定架构拉取

ARM64 · AMD64 · 多架构

latest 与「最新」

digest · 版本号 · 标签

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
xomoxcc/mqttcommander
定价查看流量套餐与价格
博客Docker 镜像公告与技术博客
专业版 · 高速稳定拉取镜像
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
50GB 仅 ¥7/年
专业版 · 高速稳定拉取镜像
50GB 仅 ¥7/年
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
用户协议·隐私政策·增值电信业务经营许可证:浙B2-20261007·©2024-2026 源码跳动©2024-2026 杭州源码跳动科技有限公司·商务合作:点击复制邮箱

更多 mqttcommander 镜像推荐

xomoxcc/postgreslocaled logo

xomoxcc/postgreslocaled

xomoxcc
该Docker镜像提供预安装pgvector扩展的PostgreSQL数据库,支持amd64/arm64多架构和德国UTF-8 locale,适用于AI/ML向量相似性搜索、RAG工作流及开发部署场景。
947 次下载
1 个月前更新
xomoxcc/sipstuff-k8s-operator logo

xomoxcc/sipstuff-k8s-operator

xomoxcc
这是一个Kubernetes Operator,通过FastAPI HTTP API创建SIP呼叫Job,支持多架构,可从任意能发HTTP请求的系统触发电话呼叫,适用于监控告警、自动化等场景。
993 次下载
4 个月前更新
xomoxcc/tang logo

xomoxcc/tang

xomoxcc
该Docker镜像提供Tang服务器解决方案,用于自动化网络绑定磁盘加密(NBDE),支持通过Clevis安全自动解锁LUKS加密分区,包含HAProxy/Nginx前端、s6-overlay进程管理及Kubernetes/k3s部署选项,具备高可用性与灵活配置能力。
915 次下载
5 个月前更新
xomoxcc/mipserver logo

xomoxcc/mipserver

xomoxcc
mipserver是一款轻量级容器友好型HTTP服务,为MicroPython的mip工具提供缓存代理和实时mpy-cross编译功能,加速包部署、降低设备带宽消耗并确保不稳定网络环境下安装的可复现性。
686 次下载
6 个月前更新

查看更多 mqttcommander 相关镜像