yenoiwesa / homebridge-daikin-airbase

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

Fan rotation speed displaying incorrectly #23

Closed jasongerbes closed 3 years ago

jasongerbes commented 3 years ago

I’ve noticed an issue where the fan rotation speed incorrectly displays as 0% while the AC is turned on.

Changing the speed via the Home app fixes the issue temporarily, but it reverts to 0% when the accessory updates.

In this screenshot, the fan speed is set to Low/33.3% but displays as 0%.

88DC37D8-520B-49FE-B8CF-ED8955CED29B

yenoiwesa commented 3 years ago

Hi @jasongerbes 👋 That sounds like a bug.

Could you please restart your Homebridge server in debug mode (add -D to the command line arguments) and check for the following log line: https://github.com/yenoiwesa/homebridge-daikin-airbase/blob/e907af7d5cb67d5d31edca4d9692c41f665b3297/src/airbase-controller.js#L133

I would like to see the aircon/get_control_info response and the response to aircon/get_model_info. Thanks!

jasongerbes commented 3 years ago

@yenoiwesa thanks for the quick response!

Here is the debug log entry:

Sent: http://10.11.11.19/skyfi/aircon/get_control_info With Values: undefined Response: {
  power: 1,
  mode: 2,
  targetTemperature: 20,
  modeTargetTemperature: { '1': 19, '2': 20, '3': 21 },
  fanRate: 3,
  fanAirside: 0,
  fanAuto: 0,
  fanDirection: 0
}
yenoiwesa commented 3 years ago

Could you also provide the response from aircon/get_model_info please?

jasongerbes commented 3 years ago

Oops, here you go:

Sent: http://10.11.11.19/skyfi/aircon/get_model_info With Values: undefined Response: {
  model: 'N/A',
  type: 'N',
  isHumidifierSupported: false,
  zoneCount: 0,
  setTemperatureSupported: true,
  fanRateSupported: true,
  fanDirectionSupported: false,
  autoModeSupported: false,
  dryModeSupported: true,
  coolMinTemperature: 16,
  coolMaxTempertature: 32,
  heatMinTemperature: 16,
  heatMaxTemperature: 32,
  fanRateSteps: 3,
  autoFanRateSupported: false
}
yenoiwesa commented 3 years ago

That is surprising. I see that you have fanRateSupported set to true and three fanRateSteps from your get_model_info response, and also that power is set to 1 (on) as well as fanRate set to 3 which should evaluate as FanSpeed.MEDIUM and thus show the fan slider at 66% 🤔

In your node_modules/homebridge-daikin-airbase directory could you add a few logging lines in this function: https://github.com/yenoiwesa/homebridge-daikin-airbase/blob/master/src/services/fan.js#L88-L113

If you, for instance, do something like:

    async getRotationSpeed(controlInfo = null) {
        const { power, fanRate } =
            controlInfo || (await this.airbase.getControlInfo());

       this.log.debug(`DEBUG-1: power: ${power}, fanRate: ${fanRate}`);

        // make sure to map power off to zero speed
        // otherwise the Home app has display consistency issues
        if (power !== Airbase.Power.ON) {
            this.log.debug(`DEBUG-2: power is off`);
            return 0;
        }

        let fanStep;
        switch (fanRate) {
            default:
            case Airbase.FanSpeed.LOW:
                fanStep = 1;
                break;
            case Airbase.FanSpeed.MEDIUM:
                fanStep = 2;
                break;
            case Airbase.FanSpeed.HIGH:
                fanStep = 3;
                break;
        }

        this.log.debug(`DEBUG-3: fanStep ${fanStep}, fanSpeedSteps ${this.fanSpeedSteps}`);

        return fanStep * this.fanSpeedSteps;
    }

And then restart the homebridge server to see what it prints.

yenoiwesa commented 3 years ago

Hey @jasongerbes, did you have time to look into what I suggested above?

yenoiwesa commented 3 years ago

@jasongerbes any news from your side?

jasongerbes commented 3 years ago

Hey @yenoiwesa, thanks for following up. I have made the suggested changes and here is the logging output:

DEBUG-1: power: 1, fanRate: 1
DEBUG-3: fanStep 1, fanSpeedSteps 33.33
yenoiwesa commented 3 years ago

Hey @jasongerbes, thank you for that! According to what you sent me, the plugin responds to HomeKit with the right information, it shows that the fan speed should be shown at 33% of the fan slider. So I don't see anything wrong with the code per se.

Can you reproduce the issue consistently? If yes, what are your exact steps? I'd like to reproduce at home. Thanks!

jasongerbes commented 3 years ago

It seems to happen when the fan speed is set to 33.33%.

Try the following reproduction steps:

  1. Set fan speed to 33.33%.
  2. Restart homebridge.
  3. Check fan speed in Home (should be 0%).
TimofeyK commented 3 years ago

33.33 and 66.66 - rounding?

yenoiwesa commented 3 years ago

Okay I have managed to reproduce this issue very consistently. It seems to be new from a recent version of iOS. HAP JS's documentation shows the RotationSpeed characteristic is supposed to accept a float value, and HomeKit does send a float value with 2 digit precision when the user moves the fan speed slider: 0, 33.33, 66.66 and 100.

The Daikin Airbase plugin returns the correct value, 33.33 for the first step, but somehow now that doesn't work anymore, and the Home app shows it as 0. It does seem to be rounding related but that is very weird, sounds like a bug Apple would have introduced in the Home app. It definitely used to work before.

Either way, I have a fix that consists in sending a ceiled value of the percent command, so now I am sending 34 instead of 33.33 and that seems to work as expected.... 🤷‍♂️

I just released version 3.0.1 of the plugin with the patch. Let me know how that goes!

jasongerbes commented 3 years ago

Thanks @yenoiwesa!

This update seems to have fixed the issue for me

yenoiwesa commented 3 years ago

That's great news! Thanks for reporting this and your patience @jasongerbes!