WebThingsIO / example-adapter

Example adapter add-on for WebThings Gateway
Mozilla Public License 2.0
34 stars 20 forks source link

PropertyChanged triggered twice #35

Open jcherrabi opened 2 years ago

jcherrabi commented 2 years ago

Hello there, the PropertyChanged event is triggered twice with this example. when the onOff is clicked, to fix i had to update the below as shown:

async setValue(value: boolean): Promise<boolean> {
    return new Promise((resolve, reject) => {
        //super
        //.setValue(value)
        // .then((updatedValue) => {
        // resolve(updatedValue);
        // this.getDevice().notifyPropertyChanged(this);
        //   })
        //   .catch((err) => {
        //       reject(err);
        //   });
        this.setCachedValue(value);
        resolve(value);
        this.getDevice().notifyPropertyChanged(this);
    });
}