bloomkd46 / homebridge-iRobot

A homebridge plugin for controlling iRobot devices
Apache License 2.0
59 stars 14 forks source link

Bug Report: Homebridge iRobot 2.1.9 Crashing Homebridge when trying to Find IP for undefined #23

Open seanmousseau opened 2 years ago

seanmousseau commented 2 years ago

Describe The Bug:

Hi,

I have three devices on my iRobot account: an s9+, an i7+ and a m6. However, it seems like i may have 2 ghost devices on my account as during the discovery process in previous versions (2.1.6, 2.1.5) it would see 2 devices called undefined as well as the 3 legitimate devices. Now, when it hits the first undefined entry, it fails and brings down homebridge. Logs excerpt below and a full log is attached. homebridge.log

To note, in version 2.1.6 and earlier, it would only add the first device it sees (my s9+) and never actually added the i7+ or the m6 even though IP discovery was successful. I saw that you are blocking the m6 now which is fine but I would like to get my i7+ added if possible.

To Reproduce:

Install 2.1.9 with undefined device on iRobot account

Expected behavior:

For undefined devices, i expect it should fail gracefully at finding an IP and move to the next device.

Logs:

[1/7/2022, 10:01:39 AM] [iRobot] Logging into iRobot...
[1/7/2022, 10:01:41 AM] [iRobot] Getting IP address for roomba: Goofy
[1/7/2022, 10:01:41 AM] [iRobot] Getting IP address for roomba: undefined
/usr/local/lib/node_modules/homebridge-irobot/dist/scripts/getRoombaIP.js:35
            console.log(child_process.execFileSync(__dirname + '/getRoombaIP.js', [blid, attempt + 1]).toString());
                        ^

ReferenceError: child_process is not defined
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-irobot/dist/scripts/getRoombaIP.js:35:25)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
[1/7/2022, 10:01:46 AM] Error: Command failed: /usr/local/lib/node_modules/homebridge-irobot/dist/scripts/getRoombaIP.js 86EB7F7B91FA4E8C80CF5101965378B2
/usr/local/lib/node_modules/homebridge-irobot/dist/scripts/getRoombaIP.js:35
            console.log(child_process.execFileSync(__dirname + '/getRoombaIP.js', [blid, attempt + 1]).toString());
                        ^

ReferenceError: child_process is not defined
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-irobot/dist/scripts/getRoombaIP.js:35:25)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

    at checkExecSyncError (node:child_process:826:11)
    at Object.execFileSync (node:child_process:864:15)
    at /usr/local/lib/node_modules/homebridge-irobot/src/getRoombas.ts:18:35
    at Array.forEach (<anonymous>)
    at getRoombas (/usr/local/lib/node_modules/homebridge-irobot/src/getRoombas.ts:16:10)
    at iRobotPlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-irobot/src/platform.ts:65:36)
    at HomebridgeAPI.<anonymous> (/usr/local/lib/node_modules/homebridge-irobot/src/platform.ts:34:12)
    at HomebridgeAPI.emit (node:events:402:35)
    at HomebridgeAPI.signalFinished (/usr/local/lib/node_modules/homebridge/src/api.ts:275:10)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:173:14)

Config:

{
    "bridge": {
        "name": "Homebridge 3226",
        "username": "0E:9D:05:E4:32:25",
        "port": 51081,
        "pin": "redacted",
        "advertiser": "ciao",
        "bind": [
            "enp1s0"
        ]
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "name": "Hubitat-v2",
            "app_url_local": "http://192.168.71.61/apps/api/",
            "app_url_cloud": "https://cloud.hubitat.com/redacted/apps/",
            "use_cloud": false,
            "app_id": 178,
            "access_token": "redacted",
            "direct_port": 8000,
            "temperature_unit": "C",
            "round_levels": true,
            "adaptive_lighting": true,
            "adaptive_lighting_offset": 0,
            "validateTokenId": false,
            "logConfig": {
                "debug": false,
                "showChanges": true
            },
            "platform": "Hubitat-v2"
        },
        {
            "controllers": [
                {
                    "address": "192.168.70.11",
                    "password": "redacted",
                    "username": "redacted"
                }
            ],
            "options": [
                "Enable.Video.Stream.Only.Low",
                "Disable.Video.Transcode",
                "Disable.18E829CFA6CA"
            ],
            "platform": "UniFi Protect"
        },
        {
            "refreshToken": "redacted",
            "hideAlarmSirenSwitch": true,
            "sendDoorbellMotionNotificationsToTv": false,
            "debug": false,
            "cameraStatusPollingSeconds": 30,
            "cameraDingsPollingSeconds": 30,
            "locationModePollingSeconds": 30,
            "locationIds": [
                "redacted"
            ],
            "onlyDeviceTypes": [
                "security-panel"
            ],
            "platform": "Ring"
        },
        {
            "platform": "Twinkly"
        },
        {
            "name": "iRobot",
            "email": "redacted",
            "password": "redacted",
            "lowBattery": 20,
            "offAction": "pause:dock",
            "status": "cycle:clean",
            "eveStatus": "inverted:cycle:clean",
            "bin": "filter:contact",
            "ignoreMultiRoomBin": true,
            "hideStuckSensor": false,
            "disableMultiRoom": false,
            "platform": "iRobotPlatform"
        }
    ],
    "disabledPlugins": [
        "homebridge-unifi-protect",
        "homebridge-roomba2"
    ]
}

Node Version:

16.13.1

NPM Version:

8.3.0

Homebridge Version:

1.3.9

Plugin Version:

2.1.9

Operating System:

Ubuntu

rcoletti116 commented 2 years ago

I saw this error as well, "child_process is not defined", but wasn't able to replicate what made it appear. After a few restart cycles it went away. Just commenting that I also believe there is a bug here.

bloomkd46 commented 2 years ago

Thank you for submitting this. the child process was my bad for not declaring it as a variable. I also made it remove any devices that it can't find the ip for which should fix your problem.

seanmousseau commented 2 years ago

Hi bloomkd46,

Thanks for the quick work! Confirmed the update no longer crashes Homebridge. However, once it hits the first undefined cloud entry, it doesn't continue to enumerate robots. Here's a peak at the logs:

[1/7/2022, 1:28:08 PM] [iRobot] Getting IP address for roomba: undefined [1/7/2022, 1:28:18 PM] [iRobot] Failed to fetch ip for roomba: undefined see below for details [1/7/2022, 1:28:18 PM] [iRobot] No Roomba Found With Blid: 86EB7F7B91FA4E8C80CF5101965378B2

After this it just continues with normal Homebridge startup.

Sean.

bloomkd46 commented 2 years ago

Could you please enable debug logging in your homebridge settings and copy the output after logging into iRobot…

seanmousseau commented 2 years ago

Here it is:

[1/8/2022, 8:29:58 AM] [iRobot] Executed didFinishLaunching callback [1/8/2022, 8:29:58 AM] [iRobot] Logging into iRobot... [1/8/2022, 8:30:00 AM] [iRobot] [ {"name": "Goofy", "blid": "redacted", "password": "redacted", "ip": "undefined"} , {"name": "undefined", "blid": "86EB7F7B91FA4E8C80CF5101965378B2", "password": "", "ip": "undefined"} , {"name": "undefined", "blid": "BFBFC877E17A4A19887200D48A90A052", "password": "", "ip": "undefined"} , {"name": "Pluto", "blid": "redacted", "password": "redacted", "ip": "undefined"} , {"name": "Mickey", "blid": "redacted", "password": "redacted", "ip": "undefined"} ]

[1/8/2022, 8:30:00 AM] [iRobot] Getting IP address for roomba: Goofy [1/8/2022, 8:30:00 AM] [iRobot] {"ver":"3","hostname":"iRobot-redacted","robotname":"Goofy","robotid":"redacted","ip":"192.168.72.61","mac":"50:14:79:77:0D:9E","sw":"soho+3.20.7+soho-release-rt421+11","sku":"s910020","nc":0,"proto":"mqtt","cap":{"carpetBoost":1,"binFullDetect":2,"oMode":2,"dockComm":1,"edge":0,"maps":3,"pmaps":5,"tLine":2,"area":1,"eco":1,"multiPass":2,"team":1,"pp":0,"lang":2,"gentle":1,"5ghz":1,"prov":3,"sched":1,"svcConf":1,"ota":2,"log":2,"langOta":0,"tileScan":1}}

[1/8/2022, 8:30:00 AM] [iRobot] Getting IP address for roomba: undefined [1/8/2022, 8:30:10 AM] [iRobot] Failed to fetch ip for roomba: undefined see below for details [1/8/2022, 8:30:10 AM] [iRobot] No Roomba Found With Blid: 86EB7F7B91FA4E8C80CF5101965378B2

[1/8/2022, 8:30:10 AM] [iRobot] Restoring existing accessory from cache: Goofy

bloomkd46 commented 2 years ago

Ok, I have found the problem and will fix it later today

seanmousseau commented 2 years ago

Hi,

I gave the update version a try. It crashes Homebridge. Here is the error I see right before it exits:

[1/15/2022, 10:31:41 AM] TypeError: Cannot read properties of undefined (reading 'name') at getRoombas (/usr/local/lib/node_modules/homebridge-irobot/src/getRoombas.ts:38:62) at iRobotPlatform.discoverDevices (/usr/local/lib/node_modules/homebridge-irobot/src/platform.ts:65:36) at HomebridgeAPI. (/usr/local/lib/node_modules/homebridge-irobot/src/platform.ts:34:12) at HomebridgeAPI.emit (node:events:402:35) at HomebridgeAPI.signalFinished (/usr/local/lib/node_modules/homebridge/src/api.ts:275:10) at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:173:14)

bloomkd46 commented 2 years ago

Ok, that is weird and I will look into it. If you are interested I will try to release some beta updates that let you manually configure your Roomba's instead of using a email/password.

seanmousseau commented 2 years ago

Sorry for the delay. Thanks for looking in to the issue. I'd be happy to test a beta when you're ready.

Sean

bloomkd46 commented 1 year ago

Please try the latest beta: npm