W8004 LoRaWAN 温控器用户手册
设备信息:型号 W8004,devEui ffffff1000047040,网关 IP 192.168.31.205,Modbus Slave ID 2,BACnet Device ID 101
1 协议概览
W8004 在 Fport 210 上报电源状态、设置温度、工作模式、风速、室内温湿度、按键锁状态、阀门状态、累计开机时长及信号质量。
1.1 上行数据协议(Fport 210)
载荷格式(Fport 210):
| 字节位置 | 字段 | 说明 |
|---|---|---|
| 0 | 保留 | 固定 0x00(协议版本) |
| 1 … N | TLV 对 | [Type(1 B)][Value(N B)] … 循环至结束 |
每个 Type 字节决定字段名称和后续 value 字节数:
| Type | Value字节数 | 字段名称 | 编码方式 | 换算 | 单位 | 说明 |
|---|---|---|---|---|---|---|
0x01 |
1 | model |
uint8 | — | — | 型号码 = 0x46 |
0x94 |
1 | rs485Addr |
uint8 | — | — | 温控器 RS485 从站地址 |
0x95 |
1+N | modbusBlock |
block | — | — | 1字节长度 N + N字节 Modbus 寄存器数据;详见下方子表 |
0x2D |
1+N | transparentSerial |
block | — | — | 1字节长度 + 原始 Modbus RTU 响应帧(可选) |
W8004 0x95 Modbus 寄存器块
块数据以 2 字节块 ID(大端)开头,后跟连续的 16 位寄存器值(每个 2 字节,大端):
普通状态块(Block ID = 0x0000):
| 寄存器 | 字段 | 编码 | 说明 |
|---|---|---|---|
| 0x0000 | 硬件 / 软件版本 | uint16 | 高字节=硬件版本,低字节=软件版本 |
| 0x0001 | 设备状态位 | 位域 | Bit 0: 0=开机, 1=关机;Bit 1: 按键锁;Bit 2: 0=阀门开, 1=关 |
| 0x0002 | 当前温度 | int16 | ÷100 → °C |
| 0x0003 | 当前湿度 | uint16 | ÷100 → %RH |
| 0x0004 | 设置温度 | int16 | ÷100 → °C |
| 0x0005 | 工作模式 | uint16 | 0=自动 1=制冷 2=制热 3=仅风扇 |
| 0x0006 | 风速 | uint16 | 0=自动 1=低速 2=中速 3=高速 4=急速 |
| 0x0007 | 累计开机时长 | uint16 | ×10 → 分钟 |
| 0x0008 | 累计阀门开启时长 | uint16 | ×10 → 分钟 |
远程控制状态块(Block ID = 0xF000):
| 寄存器 | 字段 | 说明 |
|---|---|---|
| 0xF000 | 远程电源状态 | 0=关, 1=开 |
| 0xF001 | 远程按键锁状态 | 0=解锁, 1=锁定 |
| 0xF004 | 无线信号强度 | 0–5 |
JavaScript 解码示例:
// W8004 Thermostat — Fport 210 uplink decoder
function decodeUplink(bytes) {
var i = 1, r = {};
function u8(b,o) { return b[o]&0xFF; }
function u16(b,o) { return (b[o]<<8)|b[o+1]; }
function i16(b,o) { var v=u16(b,o); return v>32767?v-65536:v; }
while (i < bytes.length) {
var t = bytes[i++];
switch (t) {
case 0x01: r.model = bytes[i++]; break;
case 0x94: r.rs485Addr = bytes[i++]; break;
case 0x95: {
// Modbus register block: 1-byte length, then register pairs
var len = bytes[i++];
var end = i + len;
var blockId = (bytes[i]<<8)|bytes[i+1];
var reg = (blockId === 0xF000) ? 0xF000 : 0x0000;
var off = i + 2;
while (off + 1 < end) {
var val = u16(bytes, off);
var valS = val > 32767 ? val - 65536 : val;
if (reg === 0x0000) {
r.hwVersion = (val>>8)&0xFF; r.swVersion = val&0xFF;
} else if (reg === 0x0001) {
r.powerState = (val&0x01) ? 0 : 1; // bit0: 0=on
r.keyLockState = (val&0x02) ? 1 : 0;
r.valveState = (val&0x04) ? 1 : 0; // bit2: 0=open
} else if (reg === 0x0002) { r.temperature = valS/100; }
else if (reg === 0x0003) { r.humidity = val/100; }
else if (reg === 0x0004) { r.setTemperature = valS/100; }
else if (reg === 0x0005) { r.workMode = val&0xFF; }
else if (reg === 0x0006) { r.fanSpeed = val&0xFF; }
else if (reg === 0x0007) { r.cumulativeOnTime = val*10; }
else if (reg === 0x0008) { r.cumulativeValveOpenTime = val*10; }
else if (reg === 0xF000) { r.remotePowerState = val&0xFF; }
else if (reg === 0xF001) { r.remoteKeyLock = val&0xFF; }
else if (reg === 0xF004) { r.signalStrength = val&0xFF; }
off += 2; reg++;
}
i = end; break;
}
case 0x2D: { var len=bytes[i++]; i+=len; break; } // skip transparent serial
default: i++; break;
}
}
return r;
}
脚本下载:LPP.zip
版本说明: LPP.js 基于 ChirpStack v4.17.0 开发和测试。不同版本的 ChirpStack JavaScript 编解码器 API 可能存在差异——如果您使用的是其他版本,请在部署前检查并根据需要调整脚本。
1.2 下行控制协议
W8004 支持电源开关、气候设置(温度/模式/风速)以及触摸屏锁定/解锁,下行使用 Fport 2。
Fport:2 — 无固定标识头;分为单寄存器写和多寄存器写两种格式
格式 A — 单寄存器写入: 06 06 [Reg_H Reg_L] [Val_H Val_L] 字节 0=0x06(指令类型),字节 1=0x06(Modbus FC06),后跟寄存器地址(2字节大端)和 16 位写值(2字节大端)。
格式 B — 多个连续寄存器写入(FC10): 07 [从站地址 0x10 起始寄存器_H 起始寄存器_L 寄存器数_H 寄存器数_L 字节数 Val0_H Val0_L... CRC_L CRC_H] 字节 0=0x07(指令类型),后跟完整的 Modbus RTU FC10 帧(含 CRC)。
控制寄存器地址映射:
| 寄存器地址 | 写入字节 | 说明 |
|---|---|---|
0x0004 |
06 06 00 04 [T_H T_L] |
设置温度(int16 ×100 °C;如 0x09C4=2500 → 25.00 °C) |
0x0005 |
06 06 00 05 00 [Mode] |
设置工作模式(0=自动 1=制冷 2=制热 3=仅风扇) |
0x0006 |
06 06 00 06 00 [Speed] |
设置风速(0=自动 1=低 2=中 3=高 4=急速) |
0xF000 |
06 06 F0 00 00 [State] |
远程电源控制(0=关 1=开) |
0xF001 |
06 06 F0 01 00 [State] |
远程触摸锁(0=解锁 1=锁定) |
JavaScript 编码器示例:
// W8004 Thermostat — Fport 2 downlink encoder
// Returns Modbus-wrapped command bytes.
function encodeDownlink(data) {
// data.setTemperature : number (°C, e.g. 25.5)
// data.workMode : 0=Auto 1=Cooling 2=Heating 3=Fan-only
// data.fanSpeed : 0=Auto 1=Low 2=Mid 3=High 4=Turbo
// data.powerState : 0=OFF 1=ON
// data.keyLockState : 0=unlock 1=lock
var writes = [];
if (data.setTemperature !== undefined) {
var v = Math.round(Number(data.setTemperature) * 100);
writes.push({reg: 0x0004, val: v & 0xFFFF});
}
if (data.workMode !== undefined) writes.push({reg:0x0005, val: Number(data.workMode)&0xFF});
if (data.fanSpeed !== undefined) writes.push({reg:0x0006, val: Number(data.fanSpeed) &0xFF});
if (data.powerState !== undefined) writes.push({reg:0xF000, val: Number(data.powerState) ?1:0});
if (data.keyLockState !== undefined) writes.push({reg:0xF001, val: Number(data.keyLockState) ?1:0});
if (writes.length === 0) return [];
// Single register → Format A: 06 06 Reg_H Reg_L Val_H Val_L
if (writes.length === 1) {
var a = writes[0];
return [0x06, 0x06, (a.reg>>8)&0xFF, a.reg&0xFF, (a.val>>8)&0xFF, a.val&0xFF];
}
// Multiple → Format B: 07 [Modbus FC10 frame with CRC16]
writes.sort(function(a,b){return a.reg-b.reg;});
var start = writes[0].reg, cnt = writes.length, byteCount = cnt*2;
var slave = data.rs485Addr || 0x01;
var frame = [slave, 0x10, (start>>8)&0xFF, start&0xFF, 0x00, cnt, byteCount];
for (var i=0; i<writes.length; i++) {
frame.push((writes[i].val>>8)&0xFF, writes[i].val&0xFF);
}
// CRC16 (Modbus)
var crc = 0xFFFF;
for (var j=0; j<frame.length; j++) {
crc ^= frame[j];
for (var b=0; b<8; b++) { crc = (crc&1) ? ((crc>>>1)^0xA001) : (crc>>>1); }
}
frame.push(crc&0xFF, (crc>>8)&0xFF);
return [0x07].concat(frame);
}
// Examples:
// encodeDownlink({setTemperature:25}) → [0x06,0x06,0x00,0x04,0x09,0xC4]
// encodeDownlink({powerState:1}) → [0x06,0x06,0xF0,0x00,0x00,0x01]
// encodeDownlink({workMode:1, fanSpeed:2})→ [0x07, …FC10 frame…]
2 获取上行数据
⚠️ 以下示例中的 IP 地址(192.168.31.205/192.168.31.193)、ChirpStack API token、Slave ID、BACnet Device ID 及 devEui 均为演示示例,请替换为实际网关 IP、ChirpStack API token 及设备参数。
2.1 ChirpStack MQTT 订阅
订阅 MQTT topic 以接收实时上行数据:
应用 ID —3ef9e6b9-ec54-4eda-86b8-a5fb46899f39是网关内置的出厂默认 ChirpStack 应用。
如果您创建了其他应用,请替换为实际的应用 ID。
网关 IP —192.168.31.205为示例网关 WAN 口 IP,
请替换为您实际的网关 IP 地址。
设备 EUI —ffffff1000047040为示例设备 EUI,
请替换为网关设备列表中显示的实际 EUI;
也可用+通配符一次订阅所有设备的数据。
# 订阅指定设备
mosquitto_sub -h 192.168.31.205 -p 1883 \
-u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/event/up"
# 订阅所有应用下所有设备(通配符)
mosquitto_sub -h 192.168.31.205 -p 1883 \
-u gateway -P mqtt88888888 \
-t "application/+/device/+/event/up"
上行数据载荷示例(JSON):
{
"devEui": "ffffff1000047040",
"fPort": 210,
"object": {
... (已解码的 LPP 字段)
}
}
2.2 IoT Hub HTTP API
发送 GET 请求获取设备最新状态:
curl -s "http://192.168.31.205:8070/api/getStatus?devEui=ffffff1000047040"
{
"success": true,
"result": {
"powerState": true,
"setTemperature": 24,
"workMode": 2,
"fanSpeed": 1,
"temperature": 29.6,
"humidity": 0,
"keyLockState": 0,
"valveState": 0,
"hardwareVersion": "0",
"model": "W8004"
}
}
2.3 IoT Hub Modbus TCP — Python 脚本
脚本下载:modbus_tcp_read.py
使用 modbus_tcp_read.py 一次性读取所有寄存器:
python3 modbus_tcp_read.py --ip 192.168.31.205 --port 502 \
--slaveId 2 --sensorType W8004
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
================================================================================================================================================================
Attribute | Addr | FC | Format | Order | Cnt | Scale | Raw(Hex) | Value | Unit
----------------------------------------------------------------------------------------------------------------------------------------------------------------
online | 6 | 03 | Bit/Bool | Big(ABCD) | 1 | x1 | 0001 | true | none
lastOnlineTime | 7 | 03 | UnixTime | Big(ABCD) | 2 | x1 | 69CC CC0B | 1775029259 | second
powerState | 9 | 03 | Bit/Bool | Big(ABCD) | 1 | x1 | 0001 | true | none
setTemperature | 10 | 03 | Int16(S) | Big(ABCD) | 1 | /100 | 0960 | 24.0 | celsius
workMode | 11 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0002 | 2.0 | none
fanSpeed | 12 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0001 | 1.0 | none
temperature | 13 | 03 | Int16(S) | Big(ABCD) | 1 | /100 | 0B90 | 29.6 | celsius
humidity | 14 | 03 | Int16(S) | Big(ABCD) | 1 | /100 | 0000 | 0.0 | percent
keyLockState | 15 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0000 | 0.0 | none
valveState | 16 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0000 | 0.0 | none
signalStrength | 17 | 03 | Int16 | Big(ABCD) | 1 | x1 | 0003 | 3.0 | none
cumulativeOnTime | 18 | 03 | Int16 | Big(ABCD) | 1 | /10 | 0000 | 0.0 | minute
... (16 fields total)
2.4 IoT Hub Modbus TCP — Modbus Poll
工具下载:Modbus Poll 9.5.0.1507.zip
- 打开 Modbus Poll,连接
192.168.31.205:502,Slave ID2 - 菜单 Setup → Read/Write Definition,功能码选 FC03,起始地址
6,长度52 - 点击 OK — 数值实时刷新
2.5 IoT Hub BACnet BIP — Python 脚本
脚本下载:bacnet_read.py
使用 bacnet_read.py 读取所有 BACnet 对象:
python3 bacnet_read.py --ip 192.168.31.205 --port 47808 --id 101
Target: 192.168.31.205:47808 | BACnet ID: 101 | Scan: 10100-10199
------------------------------------------------------------
Type | Instance | Offset | Value | Object Name
------------------------------------------------------------
BI | 10102 | 2 | active | ffffff1000047040.online
AI | 10103 | 3 | 1775029248.00 | ffffff1000047040.lastOnlineTime
BV | 10104 | 4 | active | ffffff1000047040.powerState
AV | 10105 | 5 | 24.00 | ffffff1000047040.setTemperature
AV | 10106 | 6 | 2.00 | ffffff1000047040.workMode
AV | 10107 | 7 | 1.00 | ffffff1000047040.fanSpeed
AI | 10108 | 8 | 29.60 | ffffff1000047040.temperature
AI | 10109 | 9 | 0.00 | ffffff1000047040.humidity
BV | 10110 | 10 | inactive | ffffff1000047040.keyLockState
BI | 10111 | 11 | inactive | ffffff1000047040.valveState
AI | 10112 | 12 | 3.00 | ffffff1000047040.signalStrength
AI | 10113 | 13 | 0.00 | ffffff1000047040.cumulativeOnTime
... (16 objects total)
2.6 IoT Hub BACnet BIP — YABE
工具下载:SetupYabe_v2.1.0.exe
- 打开 YABE,连接
192.168.31.205:47808 - 在设备树中展开设备 101
- 浏览 AI/BI/AV/BV/CV 对象,查看实时数值
3 发送控制指令
W8004 支持电源开关、气候设置(温度/模式/风速)以及触摸屏锁定/解锁,下行使用 Fport 2。
⚠️ 以下示例中的 IP 地址(192.168.31.205/192.168.31.193)、ChirpStack API token、Slave ID、BACnet Device ID 及 devEui 均为演示示例,请替换为实际网关 IP、ChirpStack API token 及设备参数。
脚本下载:modbus_tcp_write.py · bacnet_write.py
示例 1:开启温控器(Power ON)
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 power --value 1
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
powerState: 1
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC06 Write Single Register | Start register: 9 (4x40010) | Count: 1
powerState -> register 9 (4x40010) raw=1 signed=1
Observed values:
powerState: 1
Link confirmation time: 0.132s
Control completed in: 0.143s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 power --value 1
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
powerState: 1
Attempt 1/1: writing control values (default)...
YABE write guide:
powerState -> object binary-value,10104 | property present-value | type=binary-value | write=active
Observed values:
powerState: 1
Link confirmation time: 0.010s
Control completed in: 0.033s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"powerState":true}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","powerState":true}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"powerState": true
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","powerState":true}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"powerState": true
}
}
示例 2:关闭温控器(Power OFF)
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 power --value 0
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
powerState: 0
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC06 Write Single Register | Start register: 9 (4x40010) | Count: 1
powerState -> register 9 (4x40010) raw=0 signed=0
Observed values:
powerState: 0
Link confirmation time: 0.132s
Control completed in: 0.143s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 power --value 0
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
powerState: 0
Attempt 1/1: writing control values (default)...
YABE write guide:
powerState -> object binary-value,10104 | property present-value | type=binary-value | write=inactive
Observed values:
powerState: 0
Link confirmation time: 0.010s
Control completed in: 0.033s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"powerState":false}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","powerState":false}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"powerState": false
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","powerState":false}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"powerState": false
}
}
示例 3:单独设置目标温度(26 °C)
climate指令会同时写入setTemperature、workMode和fanSpeed。未指定的参数将使用默认值(setTemperature=23.0 °C,workMode=1,fanSpeed=1)。若只想修改其中一个属性而不影响其他设置,请使用下方的 IoT Hub HTTP 或 ChirpStack 方式,它们支持单独传送字段。
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 climate --setTemperature 26 --workMode 1 --fanSpeed 1
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
setTemperature: 26.0
workMode: 1
fanSpeed: 1
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC16 Write Multiple Registers | Start register: 10 (4x40011) | Count: 3
setTemperature -> register 10 (4x40011) raw=2600 signed=2600
workMode -> register 11 (4x40012) raw=1 signed=1
fanSpeed -> register 12 (4x40013) raw=1 signed=1
Observed values:
setTemperature: 26.0
workMode: 1
fanSpeed: 1
Link confirmation time: 0.154s
Control completed in: 0.165s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 climate --setTemperature 26 --workMode 1 --fanSpeed 1
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
setTemperature: 26.0
workMode: 1
fanSpeed: 1
Attempt 1/1: writing control values (default)...
YABE write guide:
setTemperature -> object analog-value,10105 | property present-value | type=analog-value | write=26.0
workMode -> object analog-value,10106 | property present-value | type=analog-value | write=1
fanSpeed -> object analog-value,10107 | property present-value | type=analog-value | write=1
Observed values:
setTemperature: 26.0
workMode: 1
fanSpeed: 1
Link confirmation time: 0.031s
Control completed in: 0.075s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"setTemperature":26}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","setTemperature":26}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"setTemperature": 26
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","setTemperature":26}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"setTemperature": 26
}
}
示例 4:单独设置工作模式(制冷=1)
workMode 取值:0=自动,1=制冷,2=制热,3=通风/仅风扇。通过 Python 脚本时,也会同时写入 setTemperature 和 fanSpeed 的默认值。
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 climate --setTemperature 23 --workMode 1 --fanSpeed 1
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
setTemperature: 23.0
workMode: 1
fanSpeed: 1
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC16 Write Multiple Registers | Start register: 10 (4x40011) | Count: 3
setTemperature -> register 10 (4x40011) raw=2300 signed=2300
workMode -> register 11 (4x40012) raw=1 signed=1
fanSpeed -> register 12 (4x40013) raw=1 signed=1
Observed values:
setTemperature: 23.0
workMode: 1
fanSpeed: 1
Link confirmation time: 0.154s
Control completed in: 0.165s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 climate --setTemperature 23 --workMode 1 --fanSpeed 1
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
setTemperature: 23.0
workMode: 1
fanSpeed: 1
Attempt 1/1: writing control values (default)...
YABE write guide:
setTemperature -> object analog-value,10105 | property present-value | type=analog-value | write=23.0
workMode -> object analog-value,10106 | property present-value | type=analog-value | write=1
fanSpeed -> object analog-value,10107 | property present-value | type=analog-value | write=1
Observed values:
setTemperature: 23.0
workMode: 1
fanSpeed: 1
Link confirmation time: 0.031s
Control completed in: 0.075s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"workMode":1}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","workMode":1}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"workMode": 1
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","workMode":1}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"workMode": 1
}
}
示例 5:单独设置风速(中速=2)
fanSpeed 取值:0=自动,1=低速,2=中速,3=高速,4=急速。
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 climate --setTemperature 23 --workMode 1 --fanSpeed 2
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
setTemperature: 23.0
workMode: 1
fanSpeed: 2
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC16 Write Multiple Registers | Start register: 10 (4x40011) | Count: 3
setTemperature -> register 10 (4x40011) raw=2300 signed=2300
workMode -> register 11 (4x40012) raw=1 signed=1
fanSpeed -> register 12 (4x40013) raw=2 signed=2
Observed values:
setTemperature: 23.0
workMode: 1
fanSpeed: 2
Link confirmation time: 0.154s
Control completed in: 0.165s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 climate --setTemperature 23 --workMode 1 --fanSpeed 2
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
setTemperature: 23.0
workMode: 1
fanSpeed: 2
Attempt 1/1: writing control values (default)...
YABE write guide:
setTemperature -> object analog-value,10105 | property present-value | type=analog-value | write=23.0
workMode -> object analog-value,10106 | property present-value | type=analog-value | write=1
fanSpeed -> object analog-value,10107 | property present-value | type=analog-value | write=2
Observed values:
setTemperature: 23.0
workMode: 1
fanSpeed: 2
Link confirmation time: 0.031s
Control completed in: 0.075s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"fanSpeed":2}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","fanSpeed":2}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"fanSpeed": 2
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","fanSpeed":2}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"fanSpeed": 2
}
}
示例 6:同时设置温度 + 工作模式 + 风速(26 °C,制冷,中速)
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 climate --setTemperature 26 --workMode 1 --fanSpeed 2
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
setTemperature: 26.0
workMode: 1
fanSpeed: 2
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC16 Write Multiple Registers | Start register: 10 (4x40011) | Count: 3
setTemperature -> register 10 (4x40011) raw=2600 signed=2600
workMode -> register 11 (4x40012) raw=1 signed=1
fanSpeed -> register 12 (4x40013) raw=2 signed=2
Observed values:
setTemperature: 26.0
workMode: 1
fanSpeed: 2
Link confirmation time: 0.154s
Control completed in: 0.165s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 climate --setTemperature 26 --workMode 1 --fanSpeed 2
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
setTemperature: 26.0
workMode: 1
fanSpeed: 2
Attempt 1/1: writing control values (default)...
YABE write guide:
setTemperature -> object analog-value,10105 | property present-value | type=analog-value | write=26.0
workMode -> object analog-value,10106 | property present-value | type=analog-value | write=1
fanSpeed -> object analog-value,10107 | property present-value | type=analog-value | write=2
Observed values:
setTemperature: 26.0
workMode: 1
fanSpeed: 2
Link confirmation time: 0.031s
Control completed in: 0.075s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"setTemperature":26,"workMode":1,"fanSpeed":2}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","setTemperature":26,"workMode":1,"fanSpeed":2}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"setTemperature": 26,
"workMode": 1,
"fanSpeed": 2
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","setTemperature":26,"workMode":1,"fanSpeed":2}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"setTemperature": 26,
"workMode": 1,
"fanSpeed": 2
}
}
示例 7:锁定触摸屏(keyLockState 锁定)
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 lock --value 1
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
keyLockState: 1
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC06 Write Single Register | Start register: 15 (4x40016) | Count: 1
keyLockState -> register 15 (4x40016) raw=1 signed=1
Observed values:
keyLockState: 1
Link confirmation time: 0.125s
Control completed in: 0.146s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 lock --value 1
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
keyLockState: 1
Attempt 1/1: writing control values (default)...
YABE write guide:
keyLockState -> object binary-value,10110 | property present-value | type=binary-value | write=active
Observed values:
keyLockState: 1
Link confirmation time: 0.010s
Control completed in: 0.033s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"keyLockState":true}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","keyLockState":true}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"keyLockState": true
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","keyLockState":true}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"keyLockState": true
}
}
示例 8:解锁触摸屏(keyLockState 解锁)
Modbus TCP:
python3 modbus_tcp_write.py --ip 192.168.31.205 --port 502 --slaveId 2 --sensorType W8004 lock --value 0
Target: 192.168.31.205:502 | Slave ID: 2 | Sensor: W8004
Expected values:
keyLockState: 0
Attempt 1/1: writing control values (default)...
Modbus Poll write guide:
Batch 1: FC06 Write Single Register | Start register: 15 (4x40016) | Count: 1
keyLockState -> register 15 (4x40016) raw=0 signed=0
Observed values:
keyLockState: 0
Link confirmation time: 0.125s
Control completed in: 0.146s
脚本自动写入寄存器并回读验证。输出中的 Modbus Poll write guide 部分可直接用于 Modbus Poll 手动写入的参考。
Modbus Poll:
- 连接网关(IP
192.168.31.205,端口502,Slave ID2) - 菜单 Functions → 16 Write Multiple Registers
- 参照上方脚本输出中的 Modbus Poll write guide,填写寄存器地址和数值
- 点击 Send 发送写入指令
BACnet BIP:
python3 bacnet_write.py --ip 192.168.31.205 --port 47808 --id 101 --sensorType W8004 lock --value 0
Target: 192.168.31.205:47808 | BACnet ID: 101 | Sensor: W8004
Expected values:
keyLockState: 0
Attempt 1/1: writing control values (default)...
YABE write guide:
keyLockState -> object binary-value,10110 | property present-value | type=binary-value | write=inactive
Observed values:
keyLockState: 0
Link confirmation time: 0.010s
Control completed in: 0.033s
脚本自动写入并回读验证。输出中的 YABE write guide 部分可直接用于 YABE 手动写入的参考。
YABE:
- 连接网关(IP
192.168.31.205,端口47808),展开设备 101 - 参照上方脚本输出中的 YABE write guide,找到对应对象
- 右键该对象 → Write Property,属性选
present-value,填入目标值后点击 Write
IoT Hub HTTP:
接口路径:POST http://192.168.31.205:8070/api/sendCommand
curl -s -X POST "http://192.168.31.205:8070/api/sendCommand" \
-H "Content-Type: application/json" \
-d '{"devEui":"ffffff1000047040","params":{"keyLockState":false}}'
{
"success": true,
"result": {
"devEui": "ffffff1000047040",
"status": "buffered"
}
}
ChirpStack REST API:
接口路径:POST http://192.168.31.205:8090/api/devices/ffffff1000047040/queue
curl -s -X POST 'http://192.168.31.205:8090/api/devices/ffffff1000047040/queue' \
-H 'accept: application/json' \
-H 'Grpc-Metadata-Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"flushQueue":true,"queueItem":{"confirmed":false,"isPending":false,"object":{"model":"W8004","keyLockState":false}}}'
{
"id": "4e8b2c17-5f93-4a01-b8d0-2c91ef345678"
}
格式化后的 JSON 内容:
{
"flushQueue": true,
"queueItem": {
"confirmed": false,
"isPending": false,
"object": {
"model": "W8004",
"keyLockState": false
}
}
}
ChirpStack MQTT:
mosquitto_pub -h 192.168.31.205 -p 1883 -u gateway -P mqtt88888888 \
-t "application/3ef9e6b9-ec54-4eda-86b8-a5fb46899f39/device/ffffff1000047040/command/down" \
-m '{"flushQueue":true,"devEui":"ffffff1000047040","confirmed":false,"object":{"model":"W8004","keyLockState":false}}'
格式化后的 JSON 内容:
{
"flushQueue": true,
"devEui": "ffffff1000047040",
"confirmed": false,
"object": {
"model": "W8004",
"keyLockState": false
}
}