Supereg / homebridge-http-lightbulb

Powerful http lightbulb for Homebridge: https://github.com/homebridge/homebridge
ISC License
23 stars 7 forks source link

TypeError: api.hap.AdaptiveLightingController is not a constructor #14

Closed qkevinto closed 3 years ago

qkevinto commented 3 years ago

Describe the bug

Getting this error with homebridge-http-lightbulb@v1.2.2 running on homebridge@v1.2.5 when light is configured with both brightness and colorTemperature:

TypeError: api.hap.AdaptiveLightingController is not a constructor
    at new HTTP_LIGHTBULB (/usr/lib/node_modules/homebridge-http-lightbulb/index.js:141:43)
    at /usr/lib/node_modules/homebridge/src/server.ts:355:50
    at Array.forEach (<anonymous>)
    at Server._loadAccessories (/usr/lib/node_modules/homebridge/src/server.ts:328:29)
    at Server.start (/usr/lib/node_modules/homebridge/src/server.ts:154:12)
    at cli (/usr/lib/node_modules/homebridge/src/cli.ts:80:10)
    at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)

Expected behavior

Should not throw an error.

To Reproduce

  1. Configure homebridge-http-lightbulb with a lightbulb that uses both brightness and colorTemperature configurations
  2. Restart homebridge
  3. homebridge will not start due to homebridge-http-lightbulb throwing an error

Version (output of npm list -g homebridge homebridge-http-lightbulb)

Configuration

{
    "bridge": {
        "name": "Homebridge",
        "username": "xx:xx:xx:xx:xx:xx",
        "port": 00000,
        "pin": "xxx-xx-xxx"
    },
    "accessories": [
        {
            "accessory": "HTTP-LIGHTBULB",
            "name": "Elgato Key Light",
            "debug": false,
            "onUrl": {
                "url": "http://192.168.1.50:9123/elgato/lights",
                "method": "PUT",
                "body": "{\"numberOfLights\":1,\"lights\":[{\"on\":1}]}"
            },
            "offUrl": {
                "url": "http://192.168.1.50:9123/elgato/lights",
                "method": "PUT",
                "body": "{\"numberOfLights\":1, \"lights\":[{\"on\":0}]}"
            },
            "statusUrl": "http://192.168.1.50:9123/elgato/lights",
            "statusPattern": "\"on\":1",
            "brightness": {
                "statusUrl": "http://192.168.1.50:9123/elgato/lights",
                "statusPattern": "\"brightness\":(\\d*)",
                "setUrl": {
                    "url": "http://192.168.1.50:9123/elgato/lights",
                    "method": "PUT",
                    "body": "{\"numberOfLights\":1, \"lights\":[{\"brightness\":%s }]}"
                }
            },
            "colorTemperature": {
                "statusUrl": "http://192.168.1.50:9123/elgato/lights",
                "statusPattern": "\"temperature\":(\\d*)",
                "unit": "mired",
                "minValue": 143,
                "maxValue": 344,
                "setUrl": {
                    "url": "http://192.168.1.50:9123/elgato/lights",
                    "method": "PUT",
                    "body": "{\"numberOfLights\":1,\"lights\":[{\"temperature\": %s }]}"
                }
            }
        }
    ]
}

Additional context I believe this started happening since v1.2.0 with this change: https://github.com/Supereg/homebridge-http-lightbulb/commit/639b63aae7e36cc89e9dfbafcfbd91c869ca2436

Supereg commented 3 years ago

There was indeed an issue where it wasn't properly checked if AdaptiveLighting is supported by the currently running version of homebridge. This was fixed with v1.2.3