rpc

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initiate

func Initiate(host string, port uint16, rootCertPath string, logger *zap.SugaredLogger) error

初始化

Types

type Automation added in v1.2.1

type Automation struct{}

自动化相关RPC

func GetAutomation added in v1.2.2

func GetAutomation() *Automation

获取自动化相关RPC

func (*Automation) GetDetail added in v1.2.1

func (a *Automation) GetDetail(automationId uint32) (*AutomationTask, error)

获取自动化详情

func (*Automation) GetList added in v1.2.1

func (a *Automation) GetList() (*[]AutomationTask, error)

获取自动化列表

func (*Automation) UpdateConditionLastExecuteTime added in v1.2.1

func (a *Automation) UpdateConditionLastExecuteTime(conditionId uint32, lastExecuteTime time.Time) error

更新条件最后执行时间

type AutomationAction added in v1.2.1

type AutomationAction struct {
	Id              uint32  `json:"id"`                         // ID
	Type            uint8   `json:"type"`                       // 类型
	DeviceId        *uint32 `json:"device_id,omitempty"`        // 设备ID
	DeviceAttribute *string `json:"device_attribute,omitempty"` // 设备属性
	TargetValue     *string `json:"target_value,omitempty"`     // 目标值
	ValueType       *uint8  `json:"value_type,omitempty"`       // 值类型
	DelayDuration   *uint32 `json:"delay_duration,omitempty"`   // 延时时长
	NoticeContent   *string `json:"notice_content,omitempty"`   // 通知内容
}

自动化动作

type AutomationCondition added in v1.2.1

type AutomationCondition struct {
	Id                uint32  `json:"id"`                          // ID
	ConditionType     uint8   `json:"condition_type"`              // 条件类型
	TriggerType       uint8   `json:"trigger_type"`                // 触发类型
	DeviceId          *uint32 `json:"device_id,omitempty"`         // 设备ID
	DeviceAttribute   *string `json:"device_attribute,omitempty"`  // 设备属性
	TargetValue       *string `json:"target_value,omitempty"`      // 目标值
	TimeValue         *string `json:"time_value,omitempty"`        // 时间值
	RepeatType        *uint8  `json:"repeat_type,omitempty"`       // 时间重复类型
	CustomRepeatRange []uint8 `json:"custom_repeat_range"`         // 自定义重复范围
	LastExecuteTime   *string `json:"last_execute_time,omitempty"` // 最后执行时间
}

自动化条件

type AutomationTask added in v1.2.1

type AutomationTask struct {
	Id                  uint32                `json:"id"`                          // ID
	Title               string                `json:"title"`                       // 标题
	CreateUserId        uint32                `json:"create_user_id"`              // 创建用户ID
	EffectivePeriod     uint8                 `json:"effective_period"`            // 生效时段
	PeriodBeginTime     *string               `json:"period_begin_time,omitempty"` // 时段开始时间
	PeriodEndTime       *string               `json:"period_end_time,omitempty"`   // 时段结束时间
	RepeatType          uint8                 `json:"repeat_type"`                 // 重复类型
	CustomRepeatRange   []uint8               `json:"custom_repeat_range"`         // 自定义重复范围
	IsSatisfyAll        uint8                 `json:"is_satisfy_all"`              // 是否要满足所有条件
	EventConditionList  []AutomationCondition `json:"event_condition_list"`        // 事件条件列表
	StatusConditionList []AutomationCondition `json:"status_condition_list"`       // 事件条件列表
	ActionList          []AutomationAction    `json:"action_list"`                 // 动作列表
}

自动化任务

type Device

type Device struct{}

设备相关RPC

func GetDevice

func GetDevice() *Device

获取设备相关RPC类

func (*Device) GetAttribute

func (d *Device) GetAttribute(deviceId uint32) (map[string]any, error)

获取设备属性

func (*Device) GetAttributeOptionList

func (d *Device) GetAttributeOptionList() (*[]DeviceAttributeOption, error)

获取设备属性列表

func (*Device) GetDetail

func (d *Device) GetDetail(deviceId uint32) (*DeviceDetail, error)

获取设备详情

func (*Device) GetVoiceAssistant

func (d *Device) GetVoiceAssistant(deviceId uint32) (*VoiceAssistant, error)

获取设备语音助手参数

func (*Device) GetVoiceAssistantList

func (d *Device) GetVoiceAssistantList() ([]VoiceAssistant, error)

获取语音助手参数列表

func (*Device) RecordOperationLog

func (d *Device) RecordOperationLog(deviceId uint32, platform DeviceOperationLogPlatform, attribute string, value any, valueType uint8, result DeviceOperationLogResult, reason *string, userId *uint32) error

记录设备操作日志

func (*Device) ResetOnlineStatus

func (d *Device) ResetOnlineStatus() error

重置设备在线状态

func (*Device) SaveUpgradeResult

func (d *Device) SaveUpgradeResult(upgradeTaskId uint32, result uint8, finishTime time.Time) error

保存升级结果

func (*Device) SetAttribute

func (d *Device) SetAttribute(deviceId uint32, attributeSet map[string]any) error

设置设备属性

func (*Device) UpdateOnlineStatus

func (d *Device) UpdateOnlineStatus(deviceId uint32, online bool, updateTime time.Time) error

更新设备在线状态

func (*Device) UpdateReportTime

func (d *Device) UpdateReportTime(deviceId uint32, reportTime *time.Time) error

更新设备属性上报时间

func (*Device) UpdateSlaveOnlineStatus

func (d *Device) UpdateSlaveOnlineStatus(deviceId uint32, online bool, updateTime time.Time, parentId *uint32) error

更新从设备在线状态

func (*Device) UpdateVersion

func (d *Device) UpdateVersion(deviceId uint32, versionNumber uint) error

更新设备版本信息

type DeviceAttributeOption

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"`        // 最大值
	} `json:"attribute"` // 设备属性列表
}

设备属性参数

type DeviceDetail

type DeviceDetail struct {
	Type        uint8  `json:"type"`         // 设备类型
	ConnectType uint8  `json:"connect_type"` // 连接类型
	Secret      string `json:"secret"`       // 秘钥
	PId         uint32 `json:"p_id"`         // 上层设备ID
	DataId      uint32 `json:"data_id"`      // 参数数据ID
}

设备详情

type DeviceOperationLogPlatform

type DeviceOperationLogPlatform uint8

设备操作日志平台

const (
	// 设备操作日志平台 - 管理后台
	DeviceOperationLogPlatformBackstage DeviceOperationLogPlatform = iota + 1
	// 设备操作日志平台 - 语音助手
	DeviceOperationLogPlatformAssistant
	// 设备操作日志平台 - 设备
	DeviceOperationLogPlatformDevice
	// 设备操作日志平台 - APP
	DeviceOperationLogPlatformApp
	// 设备操作日志平台 - 自动化
	DeviceOperationLogPlatformAutomation
	// 设备操作日志平台 - 桌面端
	DeviceOperationLogPlatformDesktop
	// 设备操作日志平台 - API
	DeviceOperationLogPlatformAPI
)

type DeviceOperationLogResult

type DeviceOperationLogResult uint8

设备操作日志结果

const (
	// 设备操作日志结果 - 成功
	DeviceOperationLogResultSuccess DeviceOperationLogResult = iota + 1
	// 设备操作日志结果 - 失败
	DeviceOperationLogResultFail
)

type Holiday added in v1.2.2

type Holiday struct{}

节假日相关RPC

func GetHoliday added in v1.2.2

func GetHoliday() *Holiday

func (*Holiday) IsHoliday added in v1.2.2

func (h *Holiday) IsHoliday(date time.Time) (*bool, error)

判断某个日期是否是节假日

type Request

type Request struct {
	// contains filtered or unexported fields
}

请求类

func GetRequest

func GetRequest() *Request

获取请求类

func (*Request) Send

func (r *Request) Send(methodName string, body any, responseBody any) error

发送请求

type Result

type Result[D any] struct {
	Code    ResultCode `json:"code"`    // 状态码
	Message string     `json:"message"` // 消息
	Data    D          `json:"data"`    // 数据
}

响应结果

type ResultCode

type ResultCode uint16

结果Code

const (
	// 响应Code 正常
	ResultCodeSuccess ResultCode = 0
	// 响应Code 失败
	ResultCodeError ResultCode = 10000
	// 响应Code 参数异常
	ResultCodeParamError ResultCode = 10001
	// 响应Code 操作失败
	ResultCodeActionFail ResultCode = 10002
	// 响应Code 数据不存在
	ResultCodeDataNotExist ResultCode = 10003
	// 响应Code 签名错误
	ResultCodeSignError ResultCode = 10105

	// 服务通讯失败
	ResultCodeServiceCommunicationFail ResultCode = 11000
	// 数据解析失败
	ResultCodeDataParseFail ResultCode = 11001
	// 操作不存在
	ResultCodeOperationNotExist ResultCode = 11002
	// 设备不存在
	ResultCodeDeviceNotExist ResultCode = 11003
	// 设备信息不在线
	ResultCodeDeviceOffline ResultCode = 11004
	// 设备响应超时
	ResultCodeDeviceResponseTimeout ResultCode = 11005
	// 设备属性不可操作
	ResultCodeDeviceAttributeCannotOperation ResultCode = 11006
	// 设备属性不存在
	ResultCodeDeviceAttributeNotExits ResultCode = 11007
)

type System added in v1.2.2

type System struct{}

系统相关RPC

func GetSystem added in v1.2.2

func GetSystem() *System

获取系统相关RPC

func (*System) GetSystemLocation added in v1.2.2

func (s *System) GetSystemLocation() (*SystemLocation, error)

获取系统位置

type SystemLocation added in v1.2.2

type SystemLocation struct {
	Longitude float64 `json:"longitude,string"` // 经度
	Latitude  float64 `json:"latitude,string"`  // 维度
}

系统位置

type User added in v1.2.2

type User struct{}

用户相关RPC

func GetUser added in v1.2.2

func GetUser() *User

获取用户相关RPC

func (*User) DeleteWebsocketSign added in v1.2.6

func (s *User) DeleteWebsocketSign(sign string) error

删除Websocket签名

func (*User) GetDetail added in v1.2.2

func (u *User) GetDetail(userId uint32) (*UserDetail, error)

获取用户详情

func (*User) GetWebsocketSignData added in v1.2.6

func (s *User) GetWebsocketSignData(sign string) (*WebsocketSignData, error)

获取Websocket签名信息

type UserDetail added in v1.2.2

type UserDetail struct {
	Mobile   *string `json:"mobile,omitempty"`   // 手机号
	Email    *string `json:"email,omitempty"`    // 邮箱
	Nickname *string `json:"nickname,omitempty"` // 昵称
	QQ       *string `json:"qq,omitempty"`       // QQ
	Status   uint8   `json:"status"`             // 状态
}

用户详情

type VoiceAssistant

type VoiceAssistant struct {
	Id           uint32 `json:"id"`            // ID
	Type         uint8  `json:"type"`          // 类型
	OnlineStatus uint8  `json:"online_status"` // 在线状态
	BemFaEnable  uint8  `json:"bem_fa_enable"` // 是否启用巴法平台
	BemFaName    string `json:"bem_fa_name"`   // 巴法平台名称
}

语音助手数据

type WebsocketSignData

type WebsocketSignData struct {
	UserId   uint32 `json:"user_id"`  // 用户ID
	Platform string `json:"platform"` // 平台
}

Websocket签名数据

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL