v2.4.3: Power Cycling camera causes Homebridge restart
HTS126 opened this issue · 5 comments
Describe The Bug:
I am using a Tapo C210 camera with this plugin. I have it set up to automatically reboot between 4am and 4:30am daily. This has always thrown an error in the Homebridge logs, but everything used to work fine once the camera came back online. Since updating, the error of the camera being ‘offline’ now causes the whole of homebridge to restart (I am NOT currently using a child bridge).
This is not particularly an issue in itself, I don’t mind that Homebridge restarts. However, the camera is still offline when homebridge is ready, and therefore the plugin can’t ’set up’ the camera. Therefore, the camera and its toggles are always ‘unresponsive’ until I restart homebridge again manually.
To Reproduce:
Set up a camera and then power cycle the camera. Observe the homebridge logs and see whether the camera accessory ever comes back ‘online’.
Expected behavior:
Homebridge should not restart and everything should function normally when the camera comes back online.
Logs:
(This usually occurs at around 4am but I have reproduced it this morning, causing the time differences)
[09/08/2024, 08:18:07] TypeError: fetch failed
at node:internal/deps/undici/undici:13178:13
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at /var/lib/homebridge/node_modules/homebridge-tapo-camera/src/tapoCamera.ts:455:28
at TAPOCamera.getStatus (/var/lib/homebridge/node_modules/homebridge-tapo-camera/src/tapoCamera.ts:612:26)
at CameraAccessory.getStatusAndNotify (/var/lib/homebridge/node_modules/homebridge-tapo-camera/src/cameraAccessory.ts:204:26)
[09/08/2024, 08:18:07] Got SIGTERM, shutting down Homebridge...
[09/08/2024, 08:18:12] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[09/08/2024, 08:18:17] [HB Supervisor] Restarting Homebridge...
[09/08/2024, 08:18:17] [HB Supervisor] Starting Homebridge with extra flags: -P /var/lib/homebridge/node_modules --strict-plugin-resolution
[09/08/2024, 08:18:17] [HB Supervisor] Started Homebridge v1.8.4 with PID: 1060619
[09/08/2024, 08:18:18] Loaded config.json with 6 accessories and 2 platforms.
[09/08/2024, 08:18:18] Loaded 0 cached accessories from cachedAccessories.
[09/08/2024, 08:18:18] ---
[09/08/2024, 08:18:18] Loaded plugin: homebridge-cmdtrigger@0.3.4
[09/08/2024, 08:18:18] Registering accessory 'homebridge-cmdtrigger.CmdTrigger'
[09/08/2024, 08:18:18] ---
[09/08/2024, 08:18:18] Loaded plugin: homebridge-dummy@0.9.0
[09/08/2024, 08:18:18] Registering accessory 'homebridge-dummy.DummySwitch'
[09/08/2024, 08:18:18] ---
[09/08/2024, 08:18:18] Loaded plugin: homebridge-eufy-robovac-sefa@1.1.0
[09/08/2024, 08:18:18] Registering accessory 'homebridge-eufy-robovac-sefa.Eufy RoboVac'
[09/08/2024, 08:18:18] ---
[09/08/2024, 08:18:18] Loaded plugin: homebridge-tapo-camera@2.4.3
[09/08/2024, 08:18:18] Registering platform 'homebridge-tapo-camera.tapo-camera'
[09/08/2024, 08:18:18] ---
[09/08/2024, 08:18:18] Loaded plugin: homebridge-wol@6.0.1
[09/08/2024, 08:18:18] Registering accessory 'homebridge-wol.NetworkDevice'
[09/08/2024, 08:18:18] ---
[09/08/2024, 08:18:18] Loading 2 platforms...
[09/08/2024, 08:18:18] [tapo-camera] Initializing tapo-camera platform...
[09/08/2024, 08:18:18] Loading 6 accessories...
[09/08/2024, 08:18:18] [Computer] Initializing NetworkDevice accessory...
[09/08/2024, 08:18:18] [RoboVac] Initializing Eufy RoboVac accessory...
[09/08/2024, 08:18:18] [RoboVac] RoboVac finished initializing!
[09/08/2024, 08:18:18] [Bathroom Reset Fan] Initializing DummySwitch accessory...
[09/08/2024, 08:18:18] [Bathroom Reset Fan] Setting switch to false
[09/08/2024, 08:18:18] [Bathroom Fan Timer] Initializing DummySwitch accessory...
[09/08/2024, 08:18:18] [Bathroom Start Fan Timer] Initializing DummySwitch accessory...
[09/08/2024, 08:18:18] [Restart Pi] Initializing CmdTrigger accessory...
Setup Payload:
(Redacted)
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
(Redacted)
[09/08/2024, 08:18:18] Homebridge v1.8.4 (HAP v0.12.2) (Homebridge 718A) is running on port 51266.
[09/08/2024, 08:18:18]
NOTICE TO USERS AND PLUGIN DEVELOPERS
> Homebridge 2.0 is on the way and brings some breaking changes to existing plugins.
> Please visit the following link to learn more about the changes and how to prepare:
> https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0
[09/08/2024, 08:18:18] [Tapo C210] Error during setup of camera Tapo C210 connect ECONNREFUSED 192.168.1.5:2020
Plugin Config:
NOTE: Most things are disabled because I am only currently using this plugin for the ability to control the camera privacy feature.
{
"cameras": [
{
"name": "Tapo C210",
"ipAddress": "192.168.1.5",
"password": "Redacted",
"streamUser": "Redacted",
"streamPassword": "Redacted",
"disableStreaming": true,
"disableAlarmToggleAccessory": true,
"disableNotificationsToggleAccessory": true,
"disableMotionDetectionToggleAccessory": true,
"disableLEDToggleAccessory": true,
"disableMotionSensorAccessory": true,
"eyesToggleAccessoryName": "Camera View"
}
],
"platform": "tapo-camera"
}
Environment:
- Plugin Version:
- Homebridge Version: 1.8.4
- Node.js Version: 20.16.0
- Operating System: Debian GNU/Linux Bookworm (12) - Homebridge official Raspberry Pi image
Hello! This is definitely a use-case I haven't tested it. It's most likely happening because token expires and we don't gracefully error out. I'll check during the weekend
Hi! It definitely seems like it occurs when the plugin tries to fetch information from the camera, but can’t because the camera is rebooting, and throws this error. I haven’t yet been able to test whether other communication issues (ie network issues) could cause the same problem.
Before updating the plugin I would get a similar error in the log when the camera rebooted at night, but it wouldn’t cause homebridge to restart, and everything would work as normal when the camera came back online.
I guess that using a child bridge for the plugin would likely prevent the whole of homebridge from restarting from this error, and instead just the plugin would reload. However, I assume that there’d still be the same issue that, if the camera wasn’t back online before the plugin reloaded, then the camera accessories wouldn’t be loaded until a manual restart later.
For now, I’ve taken the easy route and disabled the auto reboot on my camera :D
Thanks for the update! I've tested it and I can confirm that it now works like it used to - when there's a connection issue (camera rebooting/off, network issue, etc) it gives the error in the homebridge logs but does not cause a homebridge restart, and once the camera is back online, everything goes back to working normally! Thanks!
One thing I'd like to mention is that if I try to toggle one of the accessories such as 'eyes' while the camera is offline, this does cause homebridge to restart and then homebridge has to be restarted again manually when the camera is back online to make it work again - it seems that getting status is now resilient to the issue, while setting status isn't. I'm not sure if this also happened in the past as I've never tried it before, or if it's new too, I can send you the log for that if you like! For me, that's not an issue as it's very unlikely that I'd try to toggle the eyes accessory while the camera is offline, but other users might :)
I can work on it to be more resilient during onSet
- thanks!