通过 MQTT 协议管理立控(LIKONG)ST200TH 系列温湿度变送器。支持查询传感器数据、查看/修改设备配置、补偿校准、重启、恢复出厂、OTA升级等全部功能。
协议文档: https://docv2.likong-iot.com/products/transmitters/ST200TH/mqtt
add 保存,后续自动使用。list,有设备则直接操作,无设备则引导添加。--mac;全部 → --all;不明确 → 列出让用户选。text
{{SKILL_DIR}}/st200th_mqtt.py
query#查询温度、湿度、气压、海拔,以及设备IP、型号、固件版本、运行时间、MAC地址、网络连接方式、协议启用状态等。
bash
# 单设备(已保存仅一个时自动选择)
python3 {{SKILL_DIR}}/st200th_mqtt.py query
# 指定设备
python3 {{SKILL_DIR}}/st200th_mqtt.py query --mac <MAC>
# 查询所有已保存设备
python3 {{SKILL_DIR}}/st200th_mqtt.py query --all
# JSON 输出(适合程序解析)
python3 {{SKILL_DIR}}/st200th_mqtt.py query --json
python3 {{SKILL_DIR}}/st200th_mqtt.py query --all --json
返回数据包含:
分组字段含义单位datatemperature温度°Cdatahumidity湿度%datapressure大气压力hPadataaltitude海拔高度msysversion固件版本(如 HW:1.0.0_SDK:2.0.0)-sysruntime运行时间秒syseth_mac以太网 MAC 地址-syssta_macWiFi MAC 地址-netconnmethed连接方式(eth=以太网, wifi=无线)-netip设备 IP 地址-netdhcpDHCP 状态(1=启用, 0=静态)-netssidWiFi SSID-type-设备型号(如 ST200THPE)-protocolmqtt/http/tcpserver/tcpclient各协议启用状态(1=启用)-compensatet/h/p_compensate当前补偿值°C/%/hPasetmqtt/tcp/http_timed_report各协议定时上报状态-setmqtt/tcp/http_interval_time上报间隔秒
用户意图 → 回复策略:
用户说回复内容"查一下温湿度"温度 XX°C,湿度 XX%"气压多少"气压 XX hPa"海拔呢"海拔 XX m"设备IP是什么"IP 地址 XXX.XXX.XXX.XXX"设备什么型号"型号 ST200THPE"固件版本"HW:1.0.0_SDK:2.0.0"设备运行多久了"运行时间 Xh Xm"设备详细信息"输出全部字段
customize#查看设备当前的 MQTT、TCP、HTTP 协议配置参数。
bash
python3 {{SKILL_DIR}}/st200th_mqtt.py customize --mac <MAC>
python3 {{SKILL_DIR}}/st200th_mqtt.py customize --json
返回数据包含:
分组字段含义mqtt_infoenable, mqtt_server, mqtt_port, client_id, username, password, publish, subcribe, qos, retain, timed_report, interval_timeMQTT 完整配置tcp_infoenable, tcp_server, tcp_port, timed_report, interval_timeTCP 配置http_infoenable, http_uri, timed_report, interval_timeHTTP 配置compensatet/h/p_compensate补偿参数
compensate#校准传感器读数偏差。 立即生效,无响应返回。
bash
# 设置温度补偿 +2°C
python3 {{SKILL_DIR}}/st200th_mqtt.py compensate --mac <MAC> -t 2
# 设置湿度补偿 -5%
python3 {{SKILL_DIR}}/st200th_mqtt.py compensate --mac <MAC> -hu -5
# 设置气压补偿 +10hPa
python3 {{SKILL_DIR}}/st200th_mqtt.py compensate --mac <MAC> -p 10
# 同时设置多个
python3 {{SKILL_DIR}}/st200th_mqtt.py compensate --mac <MAC> -t 1.5 -hu -3 -p 20
# 对所有设备设置
python3 {{SKILL_DIR}}/st200th_mqtt.py compensate --all -t 2
参数范围:
-t:温度补偿 -20 ~ +20 °C-hu:湿度补偿 -20 ~ +20 %-p:气压补偿 -500 ~ +500 hParestart#立即生效,无响应返回。 修改协议配置(custom)后需重启才生效。
bash
python3 {{SKILL_DIR}}/st200th_mqtt.py restart --mac <MAC>
reset#立即生效,无响应返回。⚠️ 危险操作,必须让用户确认!
bash
python3 {{SKILL_DIR}}/st200th_mqtt.py reset --mac <MAC>
执行前应提示用户:
恢复出厂设置将清除所有配置(包括 MQTT/TCP/HTTP 设置),确定要继续吗?
ota#立即生效,无响应返回。⚠️ 需用户确认!
bash
python3 {{SKILL_DIR}}/st200th_mqtt.py ota --mac <MAC> --uri "http://10.0.0.50/likong-iot/module_v1.bin"
限制:
custom#修改 MQTT/TCP/HTTP 协议参数。 重启后生效。
bash
# 修改 MQTT 配置
python3 {{SKILL_DIR}}/st200th_mqtt.py custom --mac <MAC> --protocol mqtt \
--server "mqtt.example.com" --port 1883 \
--client-id "mydevice" --username "user" --password "pass" \
--publish-topic "/my/publish" --subscribe-topic "/my/subscribe" \
--qos 1 --timed-report 1 --interval 10
# 修改 TCP 配置
python3 {{SKILL_DIR}}/st200th_mqtt.py custom --mac <MAC> --protocol tcp \
--enable 1 --server "tcp.example.com" --port 8888 \
--timed-report 1 --interval 5
# 修改 HTTP 配置
python3 {{SKILL_DIR}}/st200th_mqtt.py custom --mac <MAC> --protocol http \
--enable 1 --http-uri "http://api.example.com" \
--timed-report 1 --interval 5
# 启用/禁用协议
python3 {{SKILL_DIR}}/st200th_mqtt.py custom --mac <MAC> --protocol tcp --enable 0
注意事项:
restart 才能生效bash
# 添加设备(首次使用)
python3 {{SKILL_DIR}}/st200th_mqtt.py add <MAC> --name "办公室"
# 列出已保存设备
python3 {{SKILL_DIR}}/st200th_mqtt.py list
# 删除设备
python3 {{SKILL_DIR}}/st200th_mqtt.py remove <MAC>
text
用户: "查一下温湿度"
↓
Agent: 执行 list → 无设备
↓
Agent: "首次使用,请提供设备的 WiFi MAC 地址(12位十六进制,如 ece334a7e044),
可在设备管理页面「基本信息」中查看。也可以给设备起个名字,方便后续识别。"
↓
用户: "ece334a7e044,就叫办公室吧"
↓
Agent: 执行 add ece334a7e044 --name "办公室"
执行 query
↓
Agent: "当前办公室温度 26.9°C,湿度 49.8%。"
错误原因建议查询超时设备离线或 MAC 错误确认设备已上电、MAC 正确MAC 地址格式无效非12位十六进制检查 MAC 格式缺少依赖 paho-mqttPython 库未安装pip3 install paho-mqttMQTT 连接失败网络或凭据问题检查网络连接补偿超出范围参数超限温度±20、湿度±20、气压±500URI 长度超限OTA URI > 128字符缩短 URI存在多个设备未指定 MAC使用 --mac 或 --all