github9984 / homebridge-xiaomi-purifier-3

Xiaomi Air Purifier 3 plugin for Homebridge
MIT License
0 stars 0 forks source link

No idle mode? #19

Open paqpaqpaq opened 3 years ago

paqpaqpaq commented 3 years ago

It somewhat bugs me that the purifier icon in Home does not show "idle" when set to automatic and is below the aqi "good" threshold, meaning aqi "excellent". Now -in automatic mode- there is only ON or OFF. When in Automatic mode the slider is set to e.g. 10%, the icon will show "Inactive" (idle), however, won't change back when the purifier comes in to action. So now it won't swtich back to ON.

In other words, when set to Automatic, the slider value will standard be on 100% and won't change with regards to its actual speed. I see this also with some humidifiers, meaning they will always be ON/Active, until you switch them off, and despite they could actually be in idle.

AirPurifier.prototype.setRotationSpeed = function (targetSpeed, callback, context) {
    this.log('setRotationSpeed ' + targetSpeed + " " + context);

    if (context === 'fromOutsideHomekit') { return callback(null) }

    try {
        if (targetSpeed > 0) {
            this.device.setSpeed(targetSpeed);
        }

        if (this.device.get('mode') == 'auto') {
            this.device.set('mode', 'favorite');
        }

        callback(null);

    } catch (e) {
        this.log('setRotationSpeed Failed : ' + e);
        callback(e);
    }
}

Now, can this part in index.js cause this issue? When set to 0 (auto) it will follow mode favorite (slider value, hence manual)

This way the purifier itself is changed to auto (which is OK), but the output in homebridge makes it believe it is on a manual speed, hence "ON"