Documentation
¶
Index ¶
- type Action
- type ActionType
- type Condition
- type ConditionSymbol
- type ConditionType
- type Config
- type DateIntervalCondition
- type DaysCondition
- type DeviceEventTrigger
- type DevicePointAction
- type DevicePointActionItem
- type DevicePointCondition
- type DevicePointTrigger
- type ExecuteTimeCondition
- type LastTimeCondition
- type MonthsCondition
- type SceneAction
- type ScheduleTrigger
- type TimesCondition
- type Trigger
- type TriggerType
- type WeeksCondition
- type YearsCondition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v1.1.1
type Action struct { Type ActionType `json:"type"` // ACondition 执行条件 Condition []Condition `json:"condition"` // Attrs 附加属性(例如:供前端存储设备组信息) Attrs map[string]interface{} `json:"attrs"` // Sleep 执行后休眠时长 Sleep string `json:"sleep"` DevicePointAction SceneAction }
type ActionType ¶
type ActionType string
ActionType 执行动作类型
const ( // ActionTypeDevicePoint 执行类型:设置设备点位 ActionTypeDevicePoint ActionType = "devicePoint" // ActionTypeLinkEdge 执行类型:触发场景联动 ActionTypeLinkEdge ActionType = "linkEdge" )
type Condition ¶ added in v1.1.1
type Condition struct { Type ConditionType `json:"type"` DevicePointCondition ExecuteTimeCondition LastTimeCondition DateIntervalCondition YearsCondition MonthsCondition DaysCondition WeeksCondition TimesCondition }
Condition 条件
type ConditionSymbol ¶ added in v1.1.1
type ConditionSymbol string
ConditionSymbol 条件符号
const ( ConditionEq ConditionSymbol = "=" ConditionNe ConditionSymbol = "!=" ConditionGt ConditionSymbol = ">" ConditionGe ConditionSymbol = ">=" ConditionLt ConditionSymbol = "<" ConditionLe ConditionSymbol = "<=" )
type ConditionType ¶ added in v1.1.1
type ConditionType string
ConditionType 条件类型
const ( // ConditionTypeDevicePoint 执行条件-设备点位 ConditionTypeDevicePoint ConditionType = "devicePoint" // ConditionTypeExecuteTime 执行条件-有些运行时间段 ConditionTypeExecuteTime ConditionType = "executeTime" // ConditionTypeLastTime 执行条件-持续时间 ConditionTypeLastTime ConditionType = "lastTime" // ConditionTypeDateInterval 执行条件-日期间隔,示例:01-01 ~ 05-01 // Deprecated: 已废弃,请拆分为多个条件,例如:年(数组)、月(数组)、日(数组)、周(数组)、时间段(数组) ConditionTypeDateInterval ConditionType = "dateInterval" // ConditionTypeYears 执行条件-年(数组) ConditionTypeYears ConditionType = "years" // ConditionTypeMonths 执行条件-月(数组) ConditionTypeMonths ConditionType = "months" // ConditionTypeDays 执行条件-日(数组) ConditionTypeDays ConditionType = "days" // ConditionTypeWeeks 执行条件-周(数组) ConditionTypeWeeks ConditionType = "weeks" // ConditionTypeTimes 执行条件-时间段(数组) ConditionTypeTimes ConditionType = "times" )
type Config ¶ added in v1.1.1
type Config struct { // ID 场景ID ID string `json:"id,omitempty"` // Enable 是否可用 Enable bool `json:"enable"` // Name 场景名称 Name string `json:"name"` // Tags 场景标签 Tags []string `json:"tags"` // Description 场景描述 Description string `json:"description"` // SilentPeriod 静默期,单位:秒 SilentPeriod int64 `json:"silentPeriod"` // Trigger 触发器 Trigger []Trigger `json:"trigger"` // Condition 执行条件 Condition []Condition `json:"condition"` // Action 执行动作 Action []Action `json:"action"` // ExecuteTime 最后执行时间 ExecuteTime time.Time }
type DateIntervalCondition ¶ added in v1.1.1
type DateIntervalCondition struct { BeginDate string `json:"begin_date"` EndDate string `json:"end_date"` }
DateIntervalCondition 日期间隔 日期格式:01-02
type DaysCondition ¶ added in v1.1.1
type DaysCondition struct {
Days []int `json:"days"`
}
DaysCondition 日期 demo: 1-31 表示1号到31号
func (DaysCondition) Verify ¶ added in v1.1.1
func (c DaysCondition) Verify(day int) bool
Verify 验证条件是否满足
type DeviceEventTrigger ¶ added in v1.1.1
type DeviceEventTrigger struct { }
DeviceEventTrigger 设备事件触发器 提示:暂未使用
type DevicePointAction ¶ added in v1.1.1
type DevicePointAction struct { // DeviceID 设备 ID DeviceID string `json:"devSn"` // DevicePoint 点位名称(兼容旧版本,后续版本将废弃) // Deprecated: 请使用 Points DevicePoint string `json:"point"` // Value 值(兼容旧版本,后续版本将废弃) // Deprecated: 请使用 Points Value interface{} `json:"value"` // Points 支持批量设置多个点位值 Points []DevicePointActionItem `json:"points"` }
DevicePointAction 设备点位动作
type DevicePointActionItem ¶ added in v1.1.1
DevicePointActionItem 设备点位动作项
type DevicePointCondition ¶ added in v1.1.1
type DevicePointCondition struct { // DeviceID 设备 ID DeviceID string `json:"devSn"` // DevicePoint 点位名称 DevicePoint string `json:"point"` // Condition 条件模式:== != > < 等 Condition ConditionSymbol `json:"condition"` // Value 条件值 Value string `json:"value"` }
DevicePointCondition 设备点位条件
type DevicePointTrigger ¶ added in v1.1.1
type DevicePointTrigger struct {
DevicePointCondition
}
DevicePointTrigger 设备点位触发器
type ExecuteTimeCondition ¶ added in v1.1.1
ExecuteTimeCondition 有效执行时间段
type LastTimeCondition ¶ added in v1.1.1
type LastTimeCondition struct {
LastTime int64 `json:"lastTime"`
}
LastTimeCondition 持续时间条件
type MonthsCondition ¶ added in v1.1.1
type MonthsCondition struct {
Months []int `json:"months"`
}
MonthsCondition 月份 demo: 1-12 表示1月到12月
func (MonthsCondition) Verify ¶ added in v1.1.1
func (c MonthsCondition) Verify(month int) bool
Verify 验证条件是否满足
type SceneAction ¶ added in v1.1.1
type SceneAction struct {
ID string `json:"id"`
}
SceneAction 触发场景联动动作
type ScheduleTrigger ¶ added in v1.1.1
type ScheduleTrigger struct {
Cron string `json:"cron"`
}
ScheduleTrigger 定时触发器
type TimesCondition ¶ added in v1.1.1
type TimesCondition struct { BeginTime string `json:"begin_time"` EndTime string `json:"end_time"` }
TimesCondition 时间段 示例:begin_time: "08:00", end_time: "18:00"
type Trigger ¶ added in v1.1.1
type Trigger struct { Type TriggerType `json:"type"` ScheduleTrigger DevicePointTrigger }
Trigger 触发器
type TriggerType ¶ added in v1.1.1
type TriggerType string
TriggerType 触发器类型
const ( // TriggerTypeSchedule 事件表触发器 TriggerTypeSchedule TriggerType = "schedule" // TriggerTypeDevicePoint 设备点位触发器 TriggerTypeDevicePoint TriggerType = "devicePoint" // TriggerTypeDeviceEvent 设备事件触发器(暂未使用) TriggerTypeDeviceEvent TriggerType = "deviceEvent" )
type WeeksCondition ¶ added in v1.1.1
type WeeksCondition struct {
Weeks []int `json:"weeks"`
}
WeeksCondition 星期 demo: 1-7 表示星期一到星期日
func (WeeksCondition) Verify ¶ added in v1.1.1
func (c WeeksCondition) Verify(week int) bool
Verify 验证条件是否满足
type YearsCondition ¶ added in v1.1.1
type YearsCondition struct {
Years []int `json:"years"`
}
YearsCondition 年份 demo: 2021-2025 表示2021年到2025年
func (YearsCondition) Verify ¶ added in v1.1.1
func (c YearsCondition) Verify(year int) bool
Verify 验证条件是否满足