4 Commits

Author SHA1 Message Date
84655ceebd 增加设备类型详情方法 2026-03-10 10:07:35 +08:00
0f0795944c 修改自动化任务返回值 2026-03-07 10:13:08 +08:00
ad24dd7335 修改设备属性参数列表返回格式 2026-02-25 14:55:55 +08:00
1f8e253f69 修改设备属性参数列表返回格式 2026-02-25 14:48:30 +08:00
2 changed files with 38 additions and 8 deletions

View File

@@ -8,6 +8,22 @@ import (
// 设备相关RPC
type Device struct{}
// 获取设备类型详情
func (d *Device) GetTypeDetail(deviceTypeId uint32) (*DeviceTypeDetail, error) {
body := map[string]any{
"device_type_id": deviceTypeId,
"field_list": []string{},
}
result := &Result[DeviceTypeDetail]{}
if err := GetRequest().Send("device.get_type_detail", body, result); err != nil {
return nil, err
}
if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message)
}
return &result.Data, nil
}
// 获取设备详情
func (d *Device) GetDetail(deviceId uint32) (*DeviceDetail, error) {
body := map[string]any{

View File

@@ -42,6 +42,19 @@ type Result[D any] struct {
Data D `json:"data"` // 数据
}
// 设备类型详情
type DeviceTypeDetail struct {
Id uint32 `json:"id"` // ID
Name string `json:"name"` // 名称
Img string `json:"img"` // 图片地址
ConnectType uint8 `json:"connect_type"` // 连接类型
AppMaxSize uint32 `json:"app_max_size"` // 应用包最大大小
HeartbeatCheckInterval uint32 `json:"heartbeat_check_interval"` // 心跳检测间隔
HeartbeatIdleTime uint32 `json:"heartbeat_idle_time"` // 心跳最大空闲时间
AllowOnlineUpgrade uint8 `json:"allow_online_upgrade"` // 是否允许在线升级
AllowVoiceAssistant uint8 `json:"allow_voice_assistant"` // 是否允许使用语言助手
}
// 设备详情
type DeviceDetail struct {
Type uint8 `json:"type"` // 设备类型
@@ -56,14 +69,14 @@ type DeviceAttributeOption struct {
Type uint8 `json:"type"` // 设备类型
ConnectType uint8 `json:"connect_type"` // 连接类型
Attribute []struct {
Type uint8 `json:"type"` // 属性类型
Name string `json:"name"` // 属性名称
Flag uint8 `json:"flag"` // 属性标识
Field string `json:"field"` // 属性字段名
Readonly bool `json:"readonly"` // 是否只读
AllowItem *[]uint8 `json:"allow_item,omitempty"` // 可用选项列表
Min *uint32 `json:"min,omitempty"` // 最小值
Max *uint32 `json:"max,omitempty"` // 最大值
Type uint8 `json:"type"` // 属性类型
Name string `json:"name"` // 属性名称
Flag uint8 `json:"flag"` // 属性标识
Field string `json:"field"` // 属性字段名
Readonly bool `json:"readonly"` // 是否只读
AllowItem *map[uint8]string `json:"allow_item,omitempty"` // 可用选项列表
Min *uint32 `json:"min,omitempty"` // 最小值
Max *uint32 `json:"max,omitempty"` // 最大值
} `json:"attribute"` // 设备属性列表
}
@@ -149,6 +162,7 @@ type AutomationTask struct {
RepeatType uint8 `json:"repeat_type"` // 重复类型
CustomRepeatRange []uint8 `json:"custom_repeat_range"` // 自定义重复范围
IsSatisfyAll uint8 `json:"is_satisfy_all"` // 是否要满足所有条件
Status uint8 `json:"status"` // 状态
EventConditionList []AutomationCondition `json:"event_condition_list"` // 事件条件列表
StatusConditionList []AutomationCondition `json:"status_condition_list"` // 事件条件列表
ActionList []AutomationAction `json:"action_list"` // 动作列表