|
|
@@ -24,6 +24,7 @@ type DeviceSceneConfig struct {
|
|
|
|
|
|
// DeviceCondition 设备场景配置
|
|
|
type DeviceCondition struct {
|
|
|
+ Key string `json:"key"` // redis key
|
|
|
DeviceType string `json:"device_type"` // 设备类型
|
|
|
DeviceId string `json:"device_id"` // 设备id
|
|
|
SubDeviceId string `json:"sub_device_id"` // 子设备id
|
|
|
@@ -142,7 +143,7 @@ func (d *DeviceSceneService) checkDeviceCondition(config DeviceSceneConfig) (boo
|
|
|
for _, v := range config.Conditions {
|
|
|
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)
|
|
|
+ args.Key = v.Key
|
|
|
var reply rpcs.ReplyStatus
|
|
|
err := server.RPCCallByName(nil, rpcs.DeviceManagerName, "DeviceManager.GetDeviceStatusByKey", args, &reply)
|
|
|
if err != nil {
|
|
|
@@ -151,7 +152,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)
|
|
|
+ fmt.Printf("判断条件:target_value:%s,value:%s,type:%d,operator:%d\n", 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 {
|