onUpdate-HAP NodeJS Javascript
我有以下代码:onUpdate-HAP NodeJS Javascript,javascript,node.js,homekit,Javascript,Node.js,Homekit,我有以下代码: cType: types.ROTATION_SPEED_CTYPE, onUpdate: function(value) { console.log("Change:",value); execute("Fan", "Fan Speed", value); }, perms: ["pw","pr","ev"], format: "float", initialValue: 100, supportEvents: false, sup
cType: types.ROTATION_SPEED_CTYPE,
onUpdate: function(value) { console.log("Change:",value); execute("Fan", "Fan Speed", value); },
perms: ["pw","pr","ev"],
format: "float",
initialValue: 100,
supportEvents: false,
supportBonjour: false,
manfDescription: "Change the speed of the fan",
designedMinValue: 0,
designedMaxValue: 99,
designedMinStep: 33,
unit: "percentage"
如何根据不同的“值”执行不同的脚本,特别是在“onUpdate”上,还有一个函数
var execute = function(accessory,characteristic,value){
console.log("executed accessory: " + accessory + ", and characteristic: " + characteristic + ", with value: " + value + "."); }
附件将有“风扇”,特性将有“风扇转速”,值将有值(0-99)
把这样的东西放在它的位置上
var execute = function(accessory,characteristic,value) {
if(value >= 30) {
...
} else
...