yenoiwesa / homebridge-daikin-airbase

A Homebridge plugin for the Daikin Airbase WiFi module
Apache License 2.0
21 stars 4 forks source link

Turning the aircon on without specifying the mode defaults to Cool #13

Closed TimofeyK closed 4 years ago

TimofeyK commented 4 years ago

I noticed recently that when the Aircon (Heat & Cool) is activated by simply tapping it in the Home app (as opposed to long press To go into details and selecting the mode) it always defaults to Cool. What’s worse - it will show the last mode status for a moment, e.g. “heating to 24°“ and then will refresh to “cooling to 24°”. This way I inadvertently ran cooling mode for a while before noticing something isn’t right

Steps to reproduce:

Looking at the debug log I see the plugin is setting Mode to Cool despite reading the current mode as Heating

35C41365-FA7A-4508-9D60-B93A26C1D2F7

Expected that only Active state will change from Off to On and the Mode will stay

TimofeyK commented 4 years ago

BTW just wanted to mention that the plugin works with no issues with Homebridge 1.xx and the zone support was flawless! :)

yenoiwesa commented 4 years ago

Hello @TimofeyK 👋

So I have no control over what commands the Home app is sending when you click on the grouped accessory.

And I have the same issue when just telling Siri to "turn on the aircon". It puts it back to cooling automatically.

In your logs, is the Home app only sending the "HeaterCooler active" command or is it also sending the "HeaterCooler targetHeatingCoolingState" (or something)?

TimofeyK commented 4 years ago

Only Active is being set, no targetHeatingCoolingState in the log. I tested that several times. That’s why I think that HomeKit is not setting the Cooling mode but the plugin logic sets it by default

TimofeyK commented 4 years ago

I think this is the code that sets Cool

https://github.com/yenoiwesa/homebridge-daikin-airbase/blob/master/src/services/heater-cooler.js

async setActive(value) {
    const active = await this.getActive();

    if (active === value) {
        // if the value is not changing, do not send any request
        // (the home app sends setActive when opening
        // the accessories details)
        return;
    }

    let controlInfo;

    if (value === Characteristic.Active.ACTIVE) {
        // must set the mode here to force the airbase
        // to leave fan/dry mode if it is the active mode
        controlInfo = await this.airbase.setControlInfo({
            power: Airbase.Power.ON,
            mode: Airbase.Mode.COOL,
        });
    } else {
        controlInfo = await this.airbase.setControlInfo({
            power: Airbase.Power.OFF,
        });
    }

    // update side effect properties
    this.updateAllServices({ controlInfo });
}

Idqeally this would keep the mode that is currently set on the controller but don’t know if this is difficult to do in the current logic

yenoiwesa commented 4 years ago

Hey @TimofeyK 👋

I just published release v2.0.1 of the plugin that includes a fix for that behaviour. Now, the plugin will only force cool mode if the previous mode was dry or fan (which are not heater/cooler modes). If on auto or heat, it will not change the mode.

Give it a try and let me know :-)

Cheers

TimofeyK commented 4 years ago

Works as described though it adds more uncertainty on what will be the mode what the aircon control activated

I wish HomeKit / Home app would remember what was the last used HeaterCooler mode so you could use that in the plugin code...

Maybe this can be done by keeping a variable updated with HeaterCooler mode every time it’s set or read via polling

yenoiwesa commented 4 years ago

I feel that's rather acceptable because you went to Dry or Fan mode in the middle so really there is no reason you would absolutely require the mode you used to be on? (Which either way you can set with a long press)

Right now the plugin is entirely stateless and relies solely on the responses from the Daikin API. Remembering the previous HeaterCooler state would make it stateful, which brings its own problems.

What do you think?

TimofeyK commented 4 years ago

Makes sense if you want to keep it stateless and I think it’s fine to keep it that way

I think this is ready to close

yenoiwesa commented 4 years ago

Closing the issue then :-)