kevbo / homebridge-sky-lite-evolve

Homebridge plugin for the BlissLights Sky Lite Evolve Star Projector
MIT License
0 stars 0 forks source link

SIGTERM when trying to run plugin #3

Open 083750043 opened 1 month ago

083750043 commented 1 month ago

Describe The Bug: SIGTERM when trying to run plugin on latest version of Homebridge and NODE.

To Reproduce:

  1. Install plugin, (latest).
  2. Enter configuration info, (access key/secret, virtual device ID).
  3. Save. Restart Homebridge.

Expected behavior: Plugin starts and doesn't SIGTERM

Logs:

[5/31/2024, 3:40:51 PM] TypeError: Cannot read properties of undefined (reading 'uuid')
    at EvolvePlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-sky-lite-evolve/src/platform.ts:75:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[5/31/2024, 3:40:51 PM] Got SIGTERM, shutting down Homebridge...

Plugin Config:

{ "cloud_credentials": { "tuya_region": "https://openapi.tuyaus.com", "tuya_access_key": "ACCESS-KEY", "tuya_secret_key": "SECRET-KEY" }, "projectors": [ { "name": "Evolve", "tuya_device_id": "DEVICE-ID", "manufacturer": "BlissLights", "model": "Sky Lite Evolve", "serial_number": "Example Serial Number" } ], "advanced_settings": { "polling_interval": 1000, "max_api_retries": 5 }, "platform": "HomebridgeSkyLiteEvolve" }

Screenshots:

Environment:

kevbo commented 1 month ago

Hmm, I can't trigger this SIGTERM based on the version differences alone. Were you able to add the Evolve okay, but then it failed afterwards?

My output:

% node --version
v20.14.0
% npm --version
10.7.0
% grep homebridge package.json
  "name": "homebridge-sky-lite-evolve",
  "author": "Kevbo (https://github.com/kevbo/homebridge-sky-lite-evolve)",
    "url": "https://github.com/kevbo/homebridge-sky-lite-evolve.git"
    "url": "https://github.com/kevbo/homebridge-sky-lite-evolve/issues"
    "homebridge-plugin",
    "homebridge",
    "homebridge": "^1.8.1"
    "homebridge": "1.8.1",
    "homebridge-config-ui-x": "^4.56.2",
% make clean install watch
rm -rf node_modules
brew update
==> Updating Homebrew...
Already up-to-date.
brew bundle
Using nodenv
Homebrew Bundle complete! 1 Brewfile dependency now installed.

Make sure to perform the post-installation tasks for nodenv if you haven't already! (brew info nodenv)

npm install --include dev
npm warn deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)

added 715 packages, and audited 716 packages in 3s

152 packages are looking for funding
  run `npm fund` for details

18 vulnerabilities (3 low, 13 moderate, 1 high, 1 critical)

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
npm run watch

> homebridge-sky-lite-evolve@1.0.0 watch
> npm run build && npm link && nodemon

> homebridge-sky-lite-evolve@1.0.0 build
> rimraf ./dist && tsc

up to date, audited 3 packages in 541ms

found 0 vulnerabilities
[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts
[nodemon] starting `tsc && homebridge -I -D`
[6/1/2024, 2:09:12 PM] Loaded config.json with 0 accessories and 2 platforms.
[6/1/2024, 2:09:12 PM] Loaded 1 cached accessories from cachedAccessories.
[6/1/2024, 2:09:12 PM] ---
[6/1/2024, 2:09:12 PM] Loaded plugin: homebridge-config-ui-x@4.56.2
[6/1/2024, 2:09:12 PM] Registering platform 'homebridge-config-ui-x.config'
[6/1/2024, 2:09:12 PM] ---
[6/1/2024, 2:09:12 PM] Loaded plugin: homebridge-sky-lite-evolve@1.0.0
[6/1/2024, 2:09:12 PM] Registering platform 'homebridge-sky-lite-evolve.HomebridgeSkyLiteEvolve'
[6/1/2024, 2:09:12 PM] ---
[6/1/2024, 2:09:12 PM] Loading 2 platforms...
[6/1/2024, 2:09:12 PM] [Config] Initializing config platform...
[6/1/2024, 2:09:12 PM] [Config] Spawning homebridge-config-ui-x with PID 22924
[6/1/2024, 2:09:12 PM] [HomebridgeSkyLiteEvolve] Initializing HomebridgeSkyLiteEvolve platform...
[6/1/2024, 2:09:12 PM] [HomebridgeSkyLiteEvolve] Finished initializing platform: undefined
[6/1/2024, 2:09:12 PM] [HomebridgeSkyLiteEvolve] Loading accessory from cache: Evolve
[6/1/2024, 2:09:12 PM] [HomebridgeSkyLiteEvolve] Executed didFinishLaunching callback
[6/1/2024, 2:09:12 PM] Publishing bridge accessory (name: Homebridge 2967, publishInfo: {
  username: '0E:1A:C1:84:29:67',
  port: 51952,
  pincode: '***-**-***',
  category: 2,
  bind: undefined,
  mdns: undefined,
  addIdentifyingMaterial: true,
  advertiser: 'bonjour-hap'
}).
Setup Payload:
X-HM://0024M5ML5325F
Scan this code with your HomeKit app on your iOS device to pair with Homebridge:

Or enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ 692-40-729 │     
    └────────────┘     

[6/1/2024, 2:09:12 PM] Homebridge v1.8.1 (HAP v0.12.0) (Homebridge 2967) is running on port 51952.
[6/1/2024, 2:09:13 PM] [HomebridgeSkyLiteEvolve] Restoring existing accessory from cache: Evolve
[6/1/2024, 2:09:13 PM] [HomebridgeSkyLiteEvolve] Initializing device...
[6/1/2024, 2:09:13 PM] [HomebridgeSkyLiteEvolve] Fetching device details for <Device ID:  <redacted>
[6/1/2024, 2:09:13 PM] [Homebridge UI] Homebridge UI v4.56.2 is listening on :: port 8581
[6/1/2024, 2:09:13 PM] [HomebridgeSkyLiteEvolve] Device initialized!
[6/1/2024, 2:09:13 PM] [HomebridgeSkyLiteEvolve] Refreshing status of <Device ID: <redacted> from Tuya cloud...
[6/1/2024, 2:09:13 PM] [HomebridgeSkyLiteEvolve] Local cloud state refreshed.
[6/1/2024, 2:09:16 PM] [HomebridgeSkyLiteEvolve] HomeKit requesting 'On' characteristic...
[6/1/2024, 2:09:16 PM] [HomebridgeSkyLiteEvolve] Get Characteristic On -> true
[6/1/2024, 2:09:19 PM] [HomebridgeSkyLiteEvolve] HomeKit requesting 'On' characteristic...
[6/1/2024, 2:09:19 PM] [HomebridgeSkyLiteEvolve] Get Characteristic On -> true
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Set Characteristic On -> false
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Pushing new state to Tuya cloud...
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Response successful:  true
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Polling to validate new remote state...
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Attempt #1
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Refreshing status of <Device ID: <redacted> from Tuya cloud...
[6/1/2024, 2:09:26 PM] [HomebridgeSkyLiteEvolve] Local cloud state refreshed.
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] Attempt #2
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] Refreshing status of <Device ID: <redacted> from Tuya cloud...
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] Local cloud state refreshed.
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] New state successfully polled!
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] HomeKit requesting 'On' characteristic...
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] Get Characteristic On -> false
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] HomeKit requesting 'On' characteristic...
[6/1/2024, 2:09:27 PM] [HomebridgeSkyLiteEvolve] Get Characteristic On -> false
[6/1/2024, 2:09:29 PM] [HomebridgeSkyLiteEvolve] HomeKit requesting 'On' characteristic...
[6/1/2024, 2:09:29 PM] [HomebridgeSkyLiteEvolve] Get Characteristic On -> false
kevbo commented 1 month ago

@083750043 Looking at the relevant code, it's trying to pull the device uuid in the response object from the tuya API. Your device is all set up correctly in Tuya cloud?

083750043 commented 1 month ago

@083750043 Looking at the relevant code, it's trying to pull the device uuid in the response object from the tuya API. Your device is all set up correctly in Tuya cloud?

That's a good question. I'm 95% sure, since the device is showing as active/online in the project, so let me fiddle with some settings and see if it gets me anywhere. Will update the thread accordingly.

083750043 commented 1 month ago

No luck sadly. Everything looks alright from what I can tell.

Random thought: The model I bought is the one without either the blue or green laser projectors; it only has the galaxy projector. I wonder if the discovery part of the code is barfing on that for some reason. No idea. 🤷

kevbo commented 1 month ago

Ah, bummer. When I get a chance I'll push a point release with some extra logging, if you're up for helping to debug. Given it's barfing on the api response (either its structure or its contents), it doesn't feel like the model is the issue, but that's just my gut.

083750043 commented 1 month ago

Yeah for sure 👍 At your leisure!

kevbo commented 1 month ago

@083750043 1.0.1 is live with an extra log wrapped around the API call:

[6/1/2024, 7:48:29 PM] [HomebridgeSkyLiteEvolve] Discovered projector: {
  result: {
    active_time: 1705796880,
    category: 'xktyd',
    category_name: 'Star projector',
    create_time: 1705796880,
    gateway_id: '',
    icon: 'smart/icon/bay1618950384308HSbj/8fe91981bd11154d8ad4a7ba224c3189.png',
    id: '<redacted>',
    ip: '<redacted>',
    lat: '<redacted>',
    local_key: "<redacted>",
    lon: '<redacted>',
    model: '',
    name: 'Evolve',
    online: true,
    owner_id: '<redacted>',
    product_id: 'jteg9ktrhbxtiicz',
    product_name: 'Evolve',
    sub: false,
    time_zone: '-06:00',
    update_time: 1717246893,
    uuid: '<redacted>'
  },
  success: true,
  t: <redacted>,
  tid: '<redacted>'
}
083750043 commented 1 month ago

@kevbo, sooooo maybe not API connection related? Still getting the same uuid error prior to the SIGTERM 🤔

[6/1/2024, 6:27:52 PM] Loaded plugin: homebridge-sky-lite-evolve@1.0.1
[6/1/2024, 6:27:52 PM] Registering platform 'homebridge-sky-lite-evolve.HomebridgeSkyLiteEvolve'
[6/1/2024, 6:27:52 PM] TypeError: Cannot read properties of undefined (reading 'uuid')
    at EvolvePlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-sky-lite-evolve/src/platform.ts:76:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
kevbo commented 1 month ago

@083750043 is debug logging enabled?

083750043 commented 1 month ago

Derp 😝

So looks like it might be a me-problem:

[6/1/2024, 7:03:32 PM] [HomebridgeSkyLiteEvolve] Discovered projector: {
  code: 60009001,
  msg: 'API permission package error. For the solution, see https://developer.tuya.com/en/docs/iot/authentication-method?id=Ka49gbaxjygox.',
  success: false,
  t: <redacted>,
  tid: '<redacted>'

I'll triple-check everything tomorrow again. I super appreciate the effort!