fix: properly implement setValue

This commit is contained in:
Martin Giger 2021-07-25 14:45:20 +02:00
parent 0f899d93b8
commit aef438e4d6
Signed by: freaktechnik
GPG key ID: AE530058EFE7FD60

View file

@ -148,6 +148,9 @@ const CONTROL_CODE = {
class IRUSBProperty extends Property {
async setValue(value) {
if(typeof value !== 'boolean') {
throw new Error(`Invalid value type ${typeof value}. Expecting boolean.`);
}
if(this.name === 'power') {
if(value) {
return this.device.sendCommand('WAKE');
@ -160,6 +163,8 @@ class IRUSBProperty extends Property {
}
return this.device.sendKey('PAUSE');
}
this.setCachedValueAndNotify(value);
return value;
}
}