利用规则将从云端要下发的属性进行处理后再下发到设备
1、从设备类型中进入→规则→属性下发预处理
2、写入如下函数,实现两个开关点动控制一个msg的输出不同字符
module.exports = function (push_attributes) {
// 读取设备当前所有属性
var attrs = Cloud.getCurrentAttributes();//获取所有属性值
if (push_attributes.switch1 !== undefined) {//只要此属性有变动,如果没有下面的程序,属性下发是不变的,如果有就按下面程序重新触发。
if (attrs.lockFlage === false) {
push_attributes.switch1 = true;
push_attributes.msm = "请解锁";
}
}
if (push_attributes.switch2 !== undefined) {
if (attrs.lockFlage === false) {
push_attributes.switch2 = true;
push_attributes.msm = "请解锁";
}
}
if (push_attributes.lockFlage !== undefined) {
if (attrs.lockFlage === false) {
push_attributes.msm = "";
}
}
return push_attributes;
};
3、实现两个开关互斥
module.exports = function (push_attributes) {
if (push_attributes.relay1 !== undefined) {
push_attributes.relay2 = !push_attributes.relay1;
}
if (push_attributes.relay2 !== undefined) {
push_attributes.relay1 = !push_attributes.relay2;
}
return push_attributes;
};

浙公网安备 33010602011771号