|
@@ -52,7 +52,7 @@ func (d *DeviceSceneService) Add(config string) error {
|
|
|
return errors.New("天气监控任务配置错误:判断条件不能为空")
|
|
|
}
|
|
|
// 初始化Ticker和停止通道
|
|
|
- c.ticker = time.NewTicker(5 * time.Minute)
|
|
|
+ c.ticker = time.NewTicker(20 * time.Second)
|
|
|
c.stopChan = make(chan struct{})
|
|
|
|
|
|
// 启动监控协程
|
|
@@ -138,7 +138,7 @@ func (d *DeviceSceneService) monitorTask(config DeviceSceneConfig) {
|
|
|
func (d *DeviceSceneService) checkDeviceCondition(config DeviceSceneConfig) (bool, error) {
|
|
|
var results []bool
|
|
|
for _, v := range config.Conditions {
|
|
|
- fmt.Printf("检查设备状态:%s", v.DeviceId)
|
|
|
+ fmt.Printf("检查设备状态:%s\n", v.DeviceId)
|
|
|
var args rpcs.ArgsGetStatus
|
|
|
args.Key = fmt.Sprintf("device:%s:status:%s%s", v.DeviceType, v.DeviceId, v.SubDeviceId)
|
|
|
var reply rpcs.ReplyStatus
|
|
@@ -149,6 +149,7 @@ func (d *DeviceSceneService) checkDeviceCondition(config DeviceSceneConfig) (boo
|
|
|
}
|
|
|
j := gjson.New(reply.Status)
|
|
|
// 判断是否满足条件并填入到result
|
|
|
+ fmt.Printf("判断条件:target_value:%s,value:%s,type:%d,operator:%d", v.TargetValue, j.Get(v.Field), v.FieldType, v.Operator)
|
|
|
results = append(results, utils.CheckValue(v.TargetValue, j.Get(v.Field), v.FieldType, v.Operator))
|
|
|
}
|
|
|
switch config.DecisionExpr {
|