onUpdate - HAP-NodeJS Javascript

341 views Asked by At

I have the following code:

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"

How could I execute a different script per different "value", specifically on the "onUpdate"

1

There are 1 answers

0
mriksman On

Further up, there is a function

var execute = function(accessory,characteristic,value){ 
    console.log("executed accessory: " + accessory + ", and characteristic: " + characteristic + ", with value: " +  value + "."); }

Accessory will have "Fan", Characteristic will have "Fan Speed" and Value will have the value (0 - 99).

Put something like this in its place;

var execute = function(accessory,characteristic,value) {

   if(value >= 30) {
    ...
   } else 
    ...