Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Fan Speed Display #332

Open
ArthurGamerHD opened this issue Feb 13, 2025 · 1 comment
Open

Inconsistent Fan Speed Display #332

ArthurGamerHD opened this issue Feb 13, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@ArthurGamerHD
Copy link

Describe The Bug:
Home app thinks the Ac Fan value is in Percentage 0-100, but the actual hardware is in Integer 0-5

To Reproduce:
Have an connected AC with range from 0-5 of fan speed, Open home app and click to edit the fan speed,
Set the speed to “60%” on the slider
Observe that the value displayed is “3%” that corresponds to 60% (3) in a 0-5 scale

Expected behavior:
The plugin should either report the value in Percentage to the home app, 60% (and internally round to the nearest speed supported) or if possible, tell the Home app the available range so the value is both in a 0-5 scale

Logs:

Not Applicable

Plugin Config:

Not Applicable

Screenshots:

Image
Image

Environment:

  • Plugin Version: V2.0.0 Beta-4
  • Homebridge Version: 2
  • Node.js Version: 22.13.1
  • NPM Version:
  • Operating System: Ubuntu
@ArthurGamerHD ArthurGamerHD added the bug Something isn't working label Feb 13, 2025
@JasonGoldenDDT
Copy link

I've spent the last two seeks working with Git hub's copilot to improve some plugins I use and this is one of them.

I found that the plugin does not currently translate the devices "windSpeed" values into the correct scale for HomeKit.
I'm currently working to implement a fix that will create a 3 segment slider in HomeKit and translate its position to my model of AC.

The API for the AC has the possible values, but not what the model actually has, so this needs the user to config or another method defined.

The AC I have for example looks like this:

`class Helper {
// ...existing code...

// Add after the category() method
static FanSpeedMap = {
    OFF: { device: 0, homekit: 0 },
    LOW: { device: 2, homekit: 33 },
    MEDIUM: { device: 4, homekit: 66 },
    HIGH: { device: 6, homekit: 100 }
};

static deviceToHomekitFanSpeed(deviceSpeed) {
    // Convert string to number if needed
    const speed = parseInt(deviceSpeed);
    for (const [key, mapping] of Object.entries(this.FanSpeedMap)) {
        if (mapping.device === speed) {
            return mapping.homekit;
        }
    }
    return 0; // Default to OFF if no match
}

static homekitToDeviceFanSpeed(homekitSpeed) {
    // Convert string to number if needed
    const speed = parseInt(homekitSpeed);
    if (speed === 0) return this.FanSpeedMap.OFF.device;
    if (speed <= 33) return this.FanSpeedMap.LOW.device;
    if (speed <= 66) return this.FanSpeedMap.MEDIUM.device;
    return this.FanSpeedMap.HIGH.device;
}

static getFanSpeedSteps() {
    return {
        minValue: 0,
        maxValue: 100,
        minStep: 45 // Forces 3-position slider
    };
}

}

// ...existing code...`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants