bwp91 / homebridge-govee

Homebridge plugin to integrate Govee devices into HomeKit.
MIT License
475 stars 49 forks source link

TypeError: Cannot convert undefined or null to object #464

Closed fastnlight0 closed 1 year ago

fastnlight0 commented 1 year ago

What issue do you have? Please be as thorough and explicit as possible.

When Homebridge is starting, it starts as normal, then suddenly crashes with the following error:

TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)
    at hasProperty (file:///usr/lib/node_modules/homebridge-govee/lib/utils/functions.js:39:68)
    at default.receiveDeviceUpdate (file:///usr/lib/node_modules/homebridge-govee/lib/platform.js:2036:44)
    at default.receiveUpdateAWS (file:///usr/lib/node_modules/homebridge-govee/lib/platform.js:1920:10)
    at DeviceClient.<anonymous> (file:///usr/lib/node_modules/homebridge-govee/lib/connection/aws.js:87:16)
    at DeviceClient.emit (node:events:513:28)
    at MqttClient.<anonymous> (/usr/lib/node_modules/homebridge-govee/node_modules/aws-iot-device-sdk/device/index.js:826:12)
    at MqttClient.emit (node:events:513:28)
    at MqttClient._handlePublish (/usr/lib/node_modules/homebridge-govee/node_modules/mqtt/lib/client.js:1277:12)
    at MqttClient._handlePacket (/usr/lib/node_modules/homebridge-govee/node_modules/mqtt/lib/client.js:410:12)

After the crash, homebridge starts itself back up again... just to crash again with the same error. All lights are initialized, then it prints info about a single light (current color info), then crashes with above error.

I restarted the physical machine. All works fine. I can even control the lights. However, after I attempted to control a specific light, it crashed at went into its infinite crash loop. I am logged into the Govee plugin using username/password. API key field is blank, but I an API key if needed.

Details of your setup.

Please paste any relevant logs below.

Please note that I have removed logs from other platforms to help reduce the clutter

[3/8/2023, 8:38:32 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -D
[3/8/2023, 8:38:32 PM] [HB Supervisor] Started Homebridge v1.6.0 with PID: 9339
[3/8/2023, 8:38:32 PM] Loaded config.json with 1 accessories and 4 platforms.
[3/8/2023, 8:38:32 PM] Loaded 15 cached accessories from cachedAccessories.
[3/8/2023, 8:38:32 PM] ---
[3/8/2023, 8:38:33 PM] Loaded plugin: homebridge-config-ui-x@4.50.2
[3/8/2023, 8:38:33 PM] Registering platform 'homebridge-config-ui-x.config'
[3/8/2023, 8:38:33 PM] ---
[3/8/2023, 8:38:34 PM] Loaded plugin: homebridge-govee@7.9.3
[3/8/2023, 8:38:34 PM] Registering platform 'homebridge-govee.Govee'
[3/8/2023, 8:38:34 PM] ---
[3/8/2023, 8:38:34 PM] Loaded plugin: homebridge-harmony@1.6.2
[3/8/2023, 8:38:34 PM] Registering platform 'homebridge-harmony.HarmonyHubWebSocket'
[3/8/2023, 8:38:34 PM] ---
[3/8/2023, 8:38:34 PM] Loaded plugin: homebridge-myq@2.9.0
[3/8/2023, 8:38:34 PM] Registering platform 'homebridge-myq.myQ'
[3/8/2023, 8:38:34 PM] ---
[3/8/2023, 8:38:34 PM] Loaded plugin: homebridge-plugin-command@1.0.3
[3/8/2023, 8:38:34 PM] Registering accessory 'homebridge-plugin-command.Command Accessory'
[3/8/2023, 8:38:34 PM] ---
[3/8/2023, 8:38:34 PM] Loading 4 platforms...
[3/8/2023, 8:38:34 PM] [myQ] Initializing myQ platform...
[3/8/2023, 8:38:34 PM] [Govee] Initializing Govee platform...
[3/8/2023, 8:38:34 PM] [Govee] Initialising plugin v7.9.3 | System linux | Node v18.14.2 | HB v1.6.0 | HAPNodeJS v0.11.0...
[3/8/2023, 8:38:34 PM] [Govee] Plugin initialised. Setting up accessories....
[3/8/2023, 8:38:34 PM] Publishing bridge accessory (name: Homebridge 479A, publishInfo: {
  username: '0E:3B:D9:36:47:9A',
  port: 51776,
  pincode: '***-**-***',
  category: 2,
  bind: undefined,
  mdns: undefined,
  addIdentifyingMaterial: true,
  advertiser: undefined
}).
Setup Payload:
X-HM://002435OZ6EHRB
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ ***-**-*** │     
    └────────────┘     

[3/8/2023, 8:38:34 PM] Homebridge v1.6.0 (HAP v0.11.0) (Homebridge 479A) is running on port 51776.
[3/8/2023, 8:38:36 PM] [Govee] [LAN] client enabled and found 0 device(s).
[3/8/2023, 8:38:36 PM] [Govee] [HTTP] client enabled and found 7 device(s).
[3/8/2023, 8:38:37 PM] [Govee] [AWS] client enabled.
[3/8/2023, 8:38:37 PM] [Govee] [API] disabling client as API key not provided.
[3/8/2023, 8:38:37 PM] [Govee] [BLE] client enabled.
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 4] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"unsupported","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 4] initialised with id [89:25:7c:a6:b0:a0:a4:90] [H6003].
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 3] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"unsupported","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 3] initialised with id [34:76:7c:a6:b0:c1:9a:36] [H6003].
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 2] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"unsupported","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 2] initialised with id [36:0c:7c:a6:b0:c1:91:d2] [H6003].
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 1] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"unsupported","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 1] initialised with id [71:68:7c:a6:b0:b1:05:99] [H6003].
[3/8/2023, 8:38:37 PM] [Govee] [Bed] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"enabled","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Bed] initialised with id [61:E4:A4:C1:38:56:34:CD] [H6141].
[3/8/2023, 8:38:37 PM] [Govee] [Office] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"enabled","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Office] initialised with id [73:7F:A4:C1:38:DC:B8:45] [H6141].
[3/8/2023, 8:38:37 PM] [Govee] [Desk] initialising with options {"adaptiveLightingShift":0,"aws":"enabled","ble":"enabled","brightnessStep":1,"colourSafeMode":false,"lan":"unsupported"}.
[3/8/2023, 8:38:37 PM] [Govee] [Desk] initialised with id [86:8F:A4:C1:38:9A:C8:26] [H6159].
noble warning: adapter does not support Bluetooth Low Energy (BLE, Bluetooth Smart).
               Try to run with environment variable:
               [sudo] NOBLE_HCI_DEVICE_ID=x node ...
[3/8/2023, 8:38:37 PM] [Govee] [Bulb 1] current colour [2600K / 380M] via adaptive lighting.
[3/8/2023, 8:38:38 PM] TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)
    at hasProperty (file:///usr/lib/node_modules/homebridge-govee/lib/utils/functions.js:39:68)
    at default.receiveDeviceUpdate (file:///usr/lib/node_modules/homebridge-govee/lib/platform.js:2036:44)
    at default.receiveUpdateAWS (file:///usr/lib/node_modules/homebridge-govee/lib/platform.js:1920:10)
    at DeviceClient.<anonymous> (file:///usr/lib/node_modules/homebridge-govee/lib/connection/aws.js:87:16)
    at DeviceClient.emit (node:events:513:28)
    at MqttClient.<anonymous> (/usr/lib/node_modules/homebridge-govee/node_modules/aws-iot-device-sdk/device/index.js:826:12)
    at MqttClient.emit (node:events:513:28)
    at MqttClient._handlePublish (/usr/lib/node_modules/homebridge-govee/node_modules/mqtt/lib/client.js:1277:12)
    at MqttClient._handlePacket (/usr/lib/node_modules/homebridge-govee/node_modules/mqtt/lib/client.js:410:12)
[3/8/2023, 8:38:38 PM] Got SIGTERM, shutting down Homebridge...
[3/8/2023, 8:38:39 PM] [Govee] ✓ Setup complete. This plugin currently has a 4.5☆ rating on HOOBS! https://bit.ly/hb-govee-review
[3/8/2023, 8:38:43 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[3/8/2023, 8:38:48 PM] [HB Supervisor] Restarting Homebridge...

I'm pretty sure it's the Desk light that is causing the issue, but I may be wrong. If anybody knows a solution, please let me know.

fastnlight0 commented 1 year ago

So, the error just stoped, and the issue is gone. Everything works perfectly. I didn't do anything apart from a few manual restarts of Homebridge. I'm gonna mark this as closed, but will re-open if the issue appears again.

fastnlight0 commented 1 year ago

It has been less than a minute. It's back

bwp91 commented 1 year ago

Hi @fastnlight0

are you able to update to the beta version of the plugin? this will include more logging and it would be interesting to see the incoming message that appears before this crash warning appears

fastnlight0 commented 1 year ago

For some reason, I think the beta version has fixed the issue, but if an error appears, I will be sure to let you know. For now, I'll close the issue back up (hopefully I don't jinx myself)

bwp91 commented 1 year ago

try changing the colour of the problematic device… 🧐

fastnlight0 commented 1 year ago

Works perfectly from the apple home app (color, brightness, power), from an Amazon Alexa device, and the Govee app (using scenes so the plugin can detect the change). The logs seem to detect these changes and no error seams to be thrown.