diff --git a/lib/devices/air-purifier-3.js b/lib/devices/air-purifier-3.js index 4f66e95..db3df10 100644 --- a/lib/devices/air-purifier-3.js +++ b/lib/devices/air-purifier-3.js @@ -183,6 +183,36 @@ module.exports = class extends AirPurifier.with( } } ); + + // Favorite Fan Level + this.defineProperty( + { did: `${id}`, siid: 10, piid: 10 }, + { + name: 'favorite_level', + mapper: v => { + const { siid, piid } = v; + + if (siid === 10 && piid === 10) { + return v.value; + } + } + } + ); + + // Motor Speed + this.defineProperty( + { did: `${id}`, siid: 10, piid: 8 }, + { + name: 'motor_speed', + mapper: v => { + const { siid, piid } = v; + + if (siid === 10 && piid === 8) { + return v.value; + } + } + } + ); } changePower(value) { @@ -241,22 +271,20 @@ module.exports = class extends AirPurifier.with( ]); } - changeFavorite(speed) { + changeFavoriteSpeed(speed) { const { id } = this.handle.api; let value = parseInt(speed); - if (value < 390) { - value = 390; + if (value < 300) { + value = 300; } - if (value > 2150) { - value = 2150; + if (value > 2300) { + value = 2300 } return this.call('set_properties', [ - { did: `${id}`, siid: 10, piid: 7, value }, - { did: `${id}`, siid: 10, piid: 8, value }, - { did: `${id}`, siid: 10, piid: 9, value } + { did: `${id}`, siid: 10, piid: 7, value } ]); } @@ -301,4 +329,21 @@ module.exports = class extends AirPurifier.with( { did: `${id}`, siid: 5, piid: 1, value: !!value } ]).then(() => null); } + + changeFavoriteLevel(level) { + const { id } = this.handle.api; + let value = parseInt(level); + + if (value < 0) { + value = 0; + } + + if (value > 14) { + value = 14; + } + + return this.call('set_properties', [ + { did: `${id}`, siid: 10, piid: 10, value } + ]); + } };