Skip to content

设备控制

接口

POST https://hotel.chintiot.com/client/room/control
Content-Type: application/json
Authorization: Bearer <token>

请求体

json
{
  "ci": { "room_id": 123 },
  "action": "turn_on",
  "mac": "001122334455",
  "payload": { "index": 0 },
  "_ip": "1.2.3.4",
  "ts": 1693900000000
}
字段类型必填说明
ci.room_idnumber房间 ID
actionstring动作类型(见下表)
macstring条件设备 MAC(12 位 hex),passthrough/execute_scene/control_lock 不需要
payloadobject条件动作参数(见下表)
_ipstring调用方 IP(写入 InfluxDB 日志)
tsnumber时间戳(control_lock 必填)

action + payload 完整对照表

开关类

action适用设备 typepayload说明
turn_on1/2/4/9/22{ index: 0 }开。subtype>0 时 index 指定子按键
turn_on5(窗帘){ deltaValue: { value: 50 } }开到指定位置(可选)
turn_on10(温控)开空调
turn_on10(红外){ type: "infrared_tv" }红外开电视/机顶盒
turn_off同上同上

窗帘

actionpayload说明
open_curtain{ position: 50 }开窗帘,position 可选(0-100)
close_curtain{ position: 50 }关窗帘
stop_curtain停止窗帘

调光灯

actionpayload说明
set_brightness{ brightness: 80 }设置亮度百分比(0-100)
increase_brightness{ brightness: 10 }增加亮度
decrease_brightness{ brightness: 10 }降低亮度
set_sub_brightness{ index: 1, brightness: 80 }设置子灯亮度
increase_sub_brightness{ index: 1, brightness: 10 }增加子灯亮度
decrease_sub_brightness{ index: 1, brightness: 10 }降低子灯亮度

色温

actionpayload说明
set_colour_temperature{ value: 50 }设置色温
increase_colour_temperature{ value: 10 }增加色温
decrease_colour_temperature{ value: 10 }降低色温

温控器

actionpayload说明
set_ac_temperature{ temperature: 26 }设置空调温度
increase_ac_temperature{ temperature: 1 }增加温度
decrease_ac_temperature{ temperature: 1 }降低温度
set_ac_mode{ mode: "cold" }模式: cold/warm/fan/auto
set_fan_speed{ speed: "high" }风速: high/middle/low/auto

红外(电视/机顶盒)

actionpayload说明
increase_volume{ type: "infrared_tv" }音量+
decrease_volume{ type: "infrared_tv" }音量-
increase_channel{ type: "infrared_tv" }频道+
decrease_channel{ type: "infrared_tv" }频道-
set_volume_mute{ type: "infrared_tv" }静音

type 可选值: infrared_tv(电视)、infrared_box(机顶盒)

场景与透传

actionpayload说明
execute_scene{ scene_id: 5 }执行场景
passthrough{ message: "533004..." }直接发送 hex 指令

门锁

actionpayload说明
control_lock{ index: 0, action: "open" }开门锁。index 指定门锁序号,ts 必填

设备 type 数字代码

type设备说明
1零火开关
2单火开关
4智能灯
5窗帘电机
9插卡取电
10温控器/红外payload.type 区分子类型
22插卡

响应

json
{
  "code": 0,
  "data": {}
}

处理流程

  1. 根据 ci.room_id 查房间,获取 room_token
  2. 根据 room_token 查网关设备,获取 server_idapi_versionmodule_code
  3. 从房间 device_info 中按 mac 查找目标设备
  4. 根据 action + 设备 type 调用 genCommand() 生成 BLE Mesh hex 指令
  5. 通过 MQTT 发布到 {topicL1}/{room_token}/ble_in
  6. 网关执行 BLE Mesh 指令,上报状态到 ble_out
  7. hapi 解析状态,更新 Redis