oogje / homebridge-i6-bigAssFans

A Homebridge plugin which allows you to control a Big Ass Fan.
MIT License
21 stars 4 forks source link

showTemperature/showHumidity seemingly not respected #38

Open knmorgan opened 3 months ago

knmorgan commented 3 months ago

Describe The Bug: The showTemperature and showHumidity flags are seemingly not respected.

To Reproduce: I have the

Expected behavior: I have the following config.

{
    "fans": [
        {
            "name": "X Fan",
            "ip": "192.168.x.1",
            "mac": "...",
            "fanModel": "Haiku H/I Series",
            "showWhooshSwitch": false,
            "showFanAutoSwitch": false,
            "showLightAutoSwitch": false,
            "showDimToWarmSwitch": false,
            "showEcoModeSwitch": false,
            "disableDirectionControl": true,
            "uplightEquipped": false,
            "showHumidity": false,
            "showTemperature": false
        },
        {
            "name": "Y Fan",
            "ip": "192.168.y.1",
            "mac": "...",
            "fanModel": "Haiku H/I Series",
            "showWhooshSwitch": false,
            "showFanAutoSwitch": false,
            "showLightAutoSwitch": false,
            "showDimToWarmSwitch": false,
            "showEcoModeSwitch": false,
            "disableDirectionControl": true,
            "uplightEquipped": false,
            "showHumidity": false,
            "showTemperature": false
        },
        {
            "name": "Z Fan",
            "ip": "192.168.z.1",
            "mac": "...",
            "fanModel": "Haiku H/I Series",
            "showWhooshSwitch": false,
            "showFanAutoSwitch": false,
            "showLightAutoSwitch": false,
            "showDimToWarmSwitch": false,
            "showEcoModeSwitch": false,
            "disableDirectionControl": true,
            "uplightEquipped": true,
            "downlightEquipped": false,
            "showHumidity": false,
            "showTemperature": false
        }
    ],
    "platform": "BigAssFans-i6"
}

However, I still get temperature and humidity accessories in homebridge (and the home app). I've tried deleting the config and re-adding, and also uninstalling and re-installing the plugin. I always get the temperature and humidity accessories.

Logs:

[16/08/2024, 17:27:51] [Homebridge UI] Running Command: sudo -E -n npm install -g homebridge-i6-bigassfans@0.6.0
[16/08/2024, 17:28:19] [Homebridge UI] Changes to config.json saved.
[16/08/2024, 17:28:20] [Homebridge UI] Homebridge restart request received
[16/08/2024, 17:28:21] [Homebridge UI] UI / Bridge settings have not changed; only restarting Homebridge process
[16/08/2024, 17:28:21] [Homebridge UI] Sending SIGTERM to Homebridge
[16/08/2024, 17:28:21] Got SIGTERM, shutting down Homebridge...
[16/08/2024, 17:28:26] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[16/08/2024, 17:28:31] [HB Supervisor] Restarting Homebridge...
[16/08/2024, 17:28:31] [HB Supervisor] Starting Homebridge with extra flags: -I
[16/08/2024, 17:28:31] [HB Supervisor] Started Homebridge v1.8.4 with PID: 2325
[16/08/2024, 17:28:32] Loaded config.json with 1 accessories and 2 platforms.
[16/08/2024, 17:28:32] Loaded 0 cached accessories from cachedAccessories.
[16/08/2024, 17:28:32] ---
[16/08/2024, 17:28:33] Loaded plugin: homebridge-config-ui-x@4.56.4
[16/08/2024, 17:28:33] Registering platform 'homebridge-config-ui-x.config'
[16/08/2024, 17:28:33] ---
[16/08/2024, 17:28:33] Loaded plugin: homebridge-i6-bigassfans@0.6.0
[16/08/2024, 17:28:33] Registering platform 'homebridge-i6-bigassfans.BigAssFans-i6'
[16/08/2024, 17:28:33] ---
[16/08/2024, 17:28:33] Loading 2 platforms...
[16/08/2024, 17:28:33] [BigAssFans-i6] Initializing BigAssFans-i6 platform...
[16/08/2024, 17:28:33] Loading 1 accessories...
[16/08/2024, 17:28:33] [BigAssFans-i6] Init - initializing devices
[16/08/2024, 17:28:33] [BigAssFans-i6] Adding new accessory: X Fan
[16/08/2024, 17:28:33] [BigAssFans-i6] Adding new accessory: Y Fan
[16/08/2024, 17:28:33] [BigAssFans-i6] Adding new accessory: Z Fan

Plugin Config:

See above.

Environment:

knmorgan commented 3 months ago

Doing some debugging, I've added the following to platformAccessory.js:

     // Current Temperature
     if (pA.capabilities.hasTempSensor) {
         if (pA.showTemperature === undefined || pA.showTemperature !== false) {
+            hbLog.info(`showTemperature: ${pA.showTemperature}`);
             pA.temperatureSensorService = pA.accessory.getService(pA.platform.Service.TemperatureSensor) ||
                 pA.accessory.addService(pA.platform.Service.TemperatureSensor);
             accessoryName = capitalizeName ? ' Temperature' : ' temperature';

And I see the following in my homebridge logs.

[16/08/2024, 20:48:14] [BigAssFans-i6] showTemperature: true
knmorgan commented 3 months ago

I just opened a pull request to address this. I'm not sure how showTemperature/showHumidity ever worked, unless something changed recently.

oogje commented 3 months ago

Thanks for this. Looks like I introduced the bug in v0.6.0-beta3. I'll insert your code into my local repository and push a beta soon.

oogje commented 3 months ago

I've pushed out homebridge-i6-bigassfans@0.6.1-beta1.