Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGTERM when trying to run plugin #3

Open
083750043 opened this issue May 31, 2024 · 17 comments
Open

SIGTERM when trying to run plugin #3

083750043 opened this issue May 31, 2024 · 17 comments
Labels
bug Something isn't working

Comments

@083750043
Copy link

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:

  • Plugin Version: v1.0.0
  • Homebridge Version: v1.8.1
  • Node.js Version: v20.14.0
  • NPM Version: v10.7.0
  • Operating System: macOS
@083750043 083750043 added the bug Something isn't working label May 31, 2024
@kevbo
Copy link
Owner

kevbo commented Jun 1, 2024

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 [email protected]: 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

> [email protected] watch
> npm run build && npm link && nodemon


> [email protected] 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: [email protected]
[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: [email protected]
[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
Copy link
Owner

kevbo commented Jun 1, 2024

@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
Copy link
Author

@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
Copy link
Author

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
Copy link
Owner

kevbo commented Jun 2, 2024

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
Copy link
Author

Yeah for sure 👍 At your leisure!

@kevbo
Copy link
Owner

kevbo commented Jun 2, 2024

@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
Copy link
Author

@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: [email protected]
[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
Copy link
Owner

kevbo commented Jun 2, 2024

@083750043 is debug logging enabled?

@083750043
Copy link
Author

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!

@adambursey
Copy link

I tried setting the plug-in up and am getting the same error as 083750043:

[7/4/2024, 11:23:18 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: 1720149798180, tid: 'ec4b20083a7d11efbecbbe9776cbd362' } [7/4/2024, 11:23:18 PM] TypeError: Cannot read properties of undefined (reading 'uuid') at EvolvePlatform.discoverDevices (/volume1/homebridge/node_modules/homebridge-sky-lite-evolve/src/platform.ts:76:35) at processTicksAndRejections (node:internal/process/task_queues:95:5)

Happy to assist in debugging if that is helpful.

@kevbo
Copy link
Owner

kevbo commented Jul 5, 2024 via email

@083750043
Copy link
Author

083750043 commented Jul 5, 2024

Apologies! Had some priority items come up and haven't been able to get back to mucking around with this. I can help test as well.

@4rft5
Copy link

4rft5 commented Aug 20, 2024

Having the same problem, plugin was working fine as of a couple days ago, restarted homebridge and now I'm getting SIGKILL also.
image

@kevbo
Copy link
Owner

kevbo commented Sep 6, 2024

I was finally able to replicate this by going nuclear on my tuya iot account and app account. After doing some research, it looks like Tuya changed its API but hasn't updated the Node.js SDK I use. Someone else has already filed a bug: tuya/tuya-connector-nodejs#17. I filed a support ticket to see if they know what's up before I spend time writing my own shitty API wrapper that does it more right than the official SDK.

The other Node.js libraries (and homebridge/homeassistant integrations) that use local communication all seem to fail for various reasons, including a jump in protocol versions in newer devices that the libraries don't support yet (codetheweb/tuyapi#325 (comment) and codetheweb/tuyapi#623 (comment)). That's just my suspicion, but in reverse engineering the network calls, the data that comes back doesn't appear to match a fixed pattern that other libraries are looking for. I'll try to find some time to debug further using tuyapi while waiting for tuya's API support to get back to me.

@kevbo
Copy link
Owner

kevbo commented Dec 10, 2024

Please try upgrading to 1.1.3 and let me know if it resolves your issues.

@4rft5
Copy link

4rft5 commented Dec 11, 2024

Please try upgrading to 1.1.3 and let me know if it resolves your issues.

seems to work for me, had to make a new dev account and app, but it is working as intended. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants