calvarium / homebridge-lifx-plugin

A plugin that adds lifx-lights in the network automatically to the homebridge, also single lights can be added manually
Apache License 2.0
30 stars 10 forks source link

Plugin enters crash loop when String light is auto discovered #40

Open ekinnear opened 2 months ago

ekinnear commented 2 months ago

Describe The Bug: When a Lifx String Light is present on the network and auto discovery is turned on, the plugin (running in a child bridge) enters a crash loop.

When auto discovery is turned off, the crash loop stops.

Even once auto discovery is turned off, the plugin is now not able to control my existing bulbs that were working prior to adding the string lights. This happens even when removing the new lights from the accessory cache.

To Reproduce: Set up one of the new string lights on the network

Expected behavior: Even if not able to control the string light, it shouldn't crash

Logs:

[homebridge-lifx-plugin] This plugin generated a warning from the characteristic 'Manufacturer': characteristic value expected string and received undefined. See https://homebridge.io/w/JtMGR for more info.
[homebridge-lifx-plugin] This plugin generated a warning from the characteristic 'Model': characteristic value expected string and received undefined. See https://homebridge.io/w/JtMGR for more info.
TypeError: Cannot read properties of undefined (reading 'color')
    at Bulb.hasColors (/usr/lib/node_modules/homebridge-lifx-plugin/src/bulb.ts:60:47)
    at LifxPlatformAccessory.bindFunctions (/usr/lib/node_modules/homebridge-lifx-plugin/src/platformAccessory.ts:70:19)
    at /usr/lib/node_modules/homebridge-lifx-plugin/src/platformAccessory.ts:25:12
    at /usr/lib/node_modules/homebridge-lifx-plugin/src/bulb.ts:29:11
    at /usr/lib/node_modules/homebridge-lifx-plugin/src/bulb.ts:90:7
    at /usr/lib/node_modules/homebridge-lifx-plugin/src/bulb.ts:125:7
    at Client.<anonymous> (/usr/lib/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/light.js:218:5)
    at Client.<anonymous> (/usr/lib/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/client.js:428:26)
    at Array.forEach (<anonymous>)
    at Client.processMessageHandlers (/usr/lib/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/client.js:414:24)
[Lifx Plugin] Child bridge process ended
[Lifx Plugin] Process Ended. Code: 1, Signal: null

Plugin Config:

        {
            "name": "Lifx Plugin",
            "duration": 0,
            "brightnessDuration": 300,
            "colorDuration": 300,
            "default": "192.168.0.201",
            "broadcast": "192.168.0.255",
            "lightOfflineTolerance": 3,
            "messageHandlerTimeout": 45000,
            "resendPacketDelay": 150,
            "resendMaxTimes": 3,
            "updates": true,
            "debug": false,
            "autoDiscover": false,
            "_bridge": {
                "username": "...",
                "port": 37047
            },
            "platform": "LifxPlugin"
        },

Environment:

greyham6 commented 1 month ago

UPDATE: I managed to prevent the crash loop on my setup by excluding my 2x LIFX DL (downlight) bulbs. I also re-added my LIFX string light to the plugin and it continued to work.

ORIGINAL POST I am also experiencing the same bug, causing the plugin to enter a crash loop. But I am experiencing it regardless of whether auto-discover is on or off. I am also not sure if it is the String light that causes it, because I added my string light to the exclusion list and it still crashes.

Log

[5/19/2024, 11:13:06 AM] [homebridge-lifx-plugin] This plugin generated a warning from the characteristic 'Model': characteristic value expected string and received undefined. See https://homebridge.io/w/JtMGR for more info.
[5/19/2024, 11:13:07 AM] TypeError: Cannot read properties of undefined (reading 'color')
    at Bulb.hasColors (/homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:60:47)
    at LifxPlatformAccessory.bindFunctions (/homebridge/node_modules/homebridge-lifx-plugin/src/platformAccessory.ts:70:19)
    at /homebridge/node_modules/homebridge-lifx-plugin/src/platformAccessory.ts:25:12
    at /homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:29:11
    at /homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:90:7
    at /homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:125:7
    at Client.<anonymous> (/homebridge/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/light.js:218:5)
    at Client.<anonymous> (/homebridge/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/client.js:428:26)
    at Array.forEach (<anonymous>)
    at Client.processMessageHandlers (/homebridge/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/client.js:414:24)
[5/19/2024, 11:13:07 AM] [homebridge-lifx-plugin] This plugin generated a warning from the characteristic 'Manufacturer': characteristic value expected string and received undefined. See https://homebridge.io/w/JtMGR for more info.
[5/19/2024, 11:13:07 AM] [homebridge-lifx-plugin] This plugin generated a warning from the characteristic 'Model': characteristic value expected string and received undefined. See https://homebridge.io/w/JtMGR for more info.
[5/19/2024, 11:13:07 AM] TypeError: Cannot read properties of undefined (reading 'color')
    at Bulb.hasColors (/homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:60:47)
    at LifxPlatformAccessory.bindFunctions (/homebridge/node_modules/homebridge-lifx-plugin/src/platformAccessory.ts:70:19)
    at /homebridge/node_modules/homebridge-lifx-plugin/src/platformAccessory.ts:25:12
    at /homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:29:11
    at /homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:90:7
    at /homebridge/node_modules/homebridge-lifx-plugin/src/bulb.ts:125:7
    at Client.<anonymous> (/homebridge/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/light.js:218:5)
    at Client.<anonymous> (/homebridge/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/client.js:428:26)
    at Array.forEach (<anonymous>)
    at Client.processMessageHandlers (/homebridge/node_modules/homebridge-lifx-plugin/node_modules/lifx-lan-client/src/lifx/client.js:414:24)
[5/19/2024, 11:13:07 AM] Got SIGTERM, shutting down Homebridge…

Plugin Config

    "name": "LIFX",
    "duration": 0,
    "brightnessDuration": 300,
    "colorDuration": 300,
    "default": "0.0.0.0",
    "broadcast": "255.255.255.255",
    "lightOfflineTolerance": 3,
    "messageHandlerTimeout": 45000,
    "resendPacketDelay": 150,
    "resendMaxTimes": 3,
    "updates": true,
    "debug": false,
    "autoDiscover": false,
    "bulbs": [
        {
            "name": "LIFX Mini Bed",
            "address": "xxx.xxx.xx.29"
        },
        {
            "name": "LIFX Mini 2 Bed",
            "address": "xxx.xxx.xx.38"
        },
        {
            "name": "Study North",
            "address": "xxx.xxx.xx.40"
        },
        {
            "name": "Study South",
            "address": "xxx.xxx.xx.47"
        },
        {
            "name": "Living Room LIFX",
            "address": "xxx.xxx.xx.21"
        }
    ],
    "excludes": [
        {
            "name": "LIFX Bedhead",
            "address": "xxx.xxx.xx.20",
            "id": "xxxREDACTEDxxx"
        }
    ],
    "platform": "LifxPlugin"
}

Environment: Plugin Version: v0.3.0 Homebridge Version: 1.8.2 Node.js Version: v20.12.2

kmahelona commented 1 month ago

I've experienced the same problem on a new A21 Bulb (with matter). I think these new lights have a different color setting which is causing the plugin to crash. It'll probably need updating to support the new lights.

nashw83 commented 2 weeks ago

Same issue here, first time trying to use the plugin (after 90% of my lights stopped working natively with HomeKit). We have around 50 DL plus a couple Clean bulb and 8 switches. Each of these don’t appear to have native support at this stage. Any help on this would be appreciated, keen to get Home back working again, also with Adaptive Lighting ;-) Probably also the DLs being the culprit, I excluded the switches but didn’t solve that.. with 50 DLs probably too time consuming to exclude them all to also rule out the Clean bulbs. the switches actually state device registered for all 4 in each switch according to logs though. Without Child Bridge gave unable to start error for Homebridge. Log attached, let me know if there’s anything I can do to help with these specific devices. homebridge-lifx-plugin-2.log.txt

Plugin v0.3.0 Homebridge v1.8.3 NodeJS v20.9.0

Further I’ve turned off auto discovery, and specified just one Clean bulb to include. In the logs it refers to loading the 70+ cached accessories and doesn’t reboot loop. Added to home app and it managed to add one A19 Clean, one Downlight and one Switch component to assign to a room and rename - and all the rest into Default Room. Both DL annd Clean lights only appear as an on/off switch and the Switches say Not Supported.

ekinnear commented 1 week ago

In the meantime, got the crashing to stop by turning off auto-discover. Then, got the rest of the bulbs working by manually adding them one by one by IP address. That hadn't worked previously, but a full reset and re-add of the bulbs seems to have fixed the older bulbs.

Will likely take a plugin update to stop crashing with the new color options for the new bulbs, though.