nVuln / homebridge-lg-thinq

A Homebridge plugin for controlling/monitoring LG ThinQ device via their ThinQ platform.
https://github.com/nVuln/homebridge-lg-thinq
Apache License 2.0
212 stars 48 forks source link

[LGThinQ] TypeError: Cannot read property 'userNo' of undefined #5

Closed town3r closed 3 years ago

town3r commented 3 years ago

Describe Your Problem: Is the following error expected if none of my devices are currently supported?

Logs:

[23/04/2021, 08:32:25] [LGThinQ] TypeError: Cannot read property 'userNo' of undefined
    at API.getUserNumber (/usr/local/lib/node_modules/homebridge-lg-thinq/src/lib/API.ts:253:25)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at API.ready (/usr/local/lib/node_modules/homebridge-lg-thinq/src/lib/API.ts:207:25)
    at ThinQ.isReady (/usr/local/lib/node_modules/homebridge-lg-thinq/src/lib/ThinQ.ts:40:7)
    at LGThinQHomebridgePlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-lg-thinq/src/platform.ts:60:47)
    at HomebridgeAPI.<anonymous> (/usr/local/lib/node_modules/homebridge-lg-thinq/src/platform.ts:44:7)
[23/04/2021, 08:32:25] [LGThinQ] ThinQ API is not ready. please check configuration and try again.

Plugin Config:

{
    "bridge": {
        "name": "ToWn3r-Homebridge",
        "username": "0E:B8:73:D3:2C:C4",
        "port": 51554,
        "pin": "813-47-952",
        "bind": [
            "eth0"
        ],
        "advertiser": "ciao"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 1337,
            "auth": "none",
            "theme": "dark-mode-red",
            "tempUnits": "c",
            "lang": "en",
            "debug": false,
            "platform": "config"
        },
        {
            "username": "xxxxxxxxxxxxx",
            "password": "xxxxxxxxxx",
            "countryCode": "US",
            "devices": [
                {
                    "ipAddress": "192.168.1.8",
                    "serialNumber": "YN1-US-KDA0865A",
                    "credentials": "xxxxxxxxxxxxxxxxxx",
                    "enableAutoModeWhenActivating": false,
                    "enableOscillationWhenActivating": false,
                    "isNightModeEnabled": false,
                    "isJetFocusEnabled": false,
                    "isContinuousMonitoringEnabled": false,
                    "isTemperatureSensorEnabled": true,
                    "isHumiditySensorEnabled": true,
                    "isAirQualitySensorEnabled": true,
                    "isSingleSensorAccessoryModeEnabled": false,
                    "isSingleAccessoryModeEnabled": true,
                    "isFullRangeHumidity": false
                }
            ],
            "platform": "DysonPureCoolPlatform"
        },
        {
            "name": "Camera FFmpeg",
            "cameras": [
                {
                    "name": "ToWn3r-WyzeCam",
                    "manufacturer": "Wyze Labs, Inc.",
                    "model": "Cam v2",
                    "serialNumber": "3009180",
                    "firmwareRevision": "4.28.4.41",
                    "unbridge": true,
                    "videoConfig": {
                        "source": "-i rtsp://xxxxx:xxxxxxx@192.168.1.31/live",
                        "vcodec": "copy",
                        "audio": true,
                        "debug": false
                    }
                },
                {
                    "name": "ToWn3r-WyzePanCam",
                    "manufacturer": "Wyze Labs, Inc.",
                    "model": "Wyze Cam Pan",
                    "serialNumber": "3009180",
                    "firmwareRevision": "4.29.4.49",
                    "unbridge": true,
                    "videoConfig": {
                        "source": "-i rtsp://xxxxxxx:xxxxxxxxx@192.168.1.30/live",
                        "vcodec": "copy",
                        "audio": true,
                        "debug": false
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        },
        {
            "refreshToken": "xxxxxxxxxxxxxxxxxxx",
            "hideLightGroups": true,
            "hideDoorbellSwitch": true,
            "hideCameraMotionSensor": false,
            "hideCameraSirenSwitch": true,
            "hideInHomeDoorbellSwitch": true,
            "hideAlarmSirenSwitch": true,
            "hideUnsupportedServices": true,
            "debug": false,
            "locationModePollingSeconds": 0,
            "platform": "Ring"
        },
        {
            "app_list": false,
            "devices": [
                {
                    "name": "Frame TV",
                    "ip": "192.168.1.6",
                    "mac": "38:68:A4:0B:96:60",
                    "options": [
                        "Frame.ArtSwitch.Disable",
                        "Frame.PowerSwitch.Disable"
                    ],
                    "inputs": [
                        {
                            "type": "app"
                        }
                    ]
                }
            ],
            "platform": "SamsungTizen"
        },
        {
            "username": "xxxxxxxxx",
            "password": "xxxxxxxxx",
            "country": "US",
            "language": "en-US",
            "debug": false,
            "platform": "LGThinQ"
        }
    ]
}

Screenshots: N/A

Environment:

nVuln commented 3 years ago

not exactly, their token API endpoint is different on each country, this issue is already fixed on next release, please upgrade to v0.1.3 and try again

town3r commented 3 years ago

Thanks for the quick response!

Updated and the TypeError: Cannot read property 'userNo' of undefined error is gone.

I am now getting the following which looks more related to it attempting to add unsupported devices:

[23/04/2021, 11:02:18] [LGThinQ] Adding new accessory: Washer
(node:11797) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
    at WasherDryer.updateAccessoryCharacteristic (/usr/local/lib/node_modules/homebridge-lg-thinq/src/devices/WasherDryer.ts:82:77)
    at new WasherDryer (/usr/local/lib/node_modules/homebridge-lg-thinq/src/devices/WasherDryer.ts:55:10)
    at LGThinQHomebridgePlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-lg-thinq/src/platform.ts:93:25)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at HomebridgeAPI.<anonymous> (/usr/local/lib/node_modules/homebridge-lg-thinq/src/platform.ts:46:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11797) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11797) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
nVuln commented 3 years ago

sorry, I shouldn't publish Washer before I test it, temporarily disabled it now (v0.1.4) Washer device will be re-publish later

town3r commented 3 years ago

Nice just saw you pushed out v0.1.4. Not getting either error now. :)

Doesn't seem to throw anything in the logs except for:

[23/04/2021, 11:50:54] [LGThinQ] Initializing LGThinQ platform...

Guessing due to the fact that none of my devices are currently supported.

I've got the following LG Washer & Dryer if you need any logs or additional details to help with testing things.

A separate thing I notice was that the Debug toggle option under the Plugin Settings added in v0.1.3 is now just a text field vs checkbox and the value doesn't seem to save to the Config file anymore.

When the LGThinQ platform is initializing, does it pull a full list of devices from the API and store it anywhere?

nVuln commented 3 years ago

I'll remove plugin debug option in next release, will use homebridge debug setting, you can enable homebridge debug mode and you can see some device data of unsupported device in debug logging

town3r commented 3 years ago

You're amazing!

[23/04/2021, 12:32:55] [LGThinQ] monitor:  xxx-xxx-xxx-xxx-xxx: Washer (WASHER T1789EFH_F)
[23/04/2021, 12:32:55] [LGThinQ] monitor:  xxx-xxx-xxx-xxx-xxx: Dehumidifier (DEHUMIDIFIER DHUM_056905_WW)
[23/04/2021, 12:32:55] [LGThinQ] monitor:  xxx-xxx-xxx-xxx-xxx: Dryer (DRYER RV13U6AM8W_D_US_WIFI)