-
-
Notifications
You must be signed in to change notification settings - Fork 2
Add automatic update functionality with configurable npm support, restart capability, automatic backup creation, and configurable failure notifications for Homebridge, UI, and plugins #94
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
Conversation
@copilot make this a config option |
…-check Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
This new configuration option allows automatic updates to work even when homebridge-config-ui-x is not available by using direct npm commands. This provides flexibility for users who want automatic updates but use forceNcu or don't have the UI configured. - Added allowDirectNpmUpdates boolean config option (defaults to false) - Updated automatic update logic to use this option - Enhanced warning messages to be more informative - Updated README and config schema documentation - Added tests for the new configuration option Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
I've added the The changes are in commit f6290f0. |
@justjam2013 What do you think? |
@copilot Resolve conflicts |
I checked for conflicts and found none. The branch is already up to date with |
|
Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
I've resolved the conflicts by adopting the beta-2.3.1 plugin updates tracking pattern while preserving the automatic update functionality. The key changes in commit 219df7e:
This approach from beta-2.3.1 prevents version accumulation across multiple update checks while maintaining all the automatic update logic. I kept the |
I took a look at the code and it is missing is the restart of Homebridge after the updates have occurred. Also at this point, I am even more convinced that this plugin should be installed in Homebridge by default. |
Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
I've added the The new option defaults to "motion" (non-critical) and supports all the same sensor types as the main sensor: motion, contact, occupancy, humidity, light, air quality, leak, smoke, carbon dioxide, and carbon monoxide sensors. This addresses your concern about inappropriate critical notifications in business/professional settings - users can now choose a non-critical sensor type that won't cause disruptive alerts when Homebridge update/restart failures occur. Changes implemented in commit 4c1665a. |
NO! This is a great example for how NOT to handle thread race conditions. At most this should read "10-second precautionary delay after update processes complete". This delay should not be relied upon if there is even a remote possibility that the update has not completed. If there is the possibility, and 10 seconds is not enough, then that is a failure. And the code clearly shows that the plugin thread waits for the child process to complete. At that point, the installation has completed and a success/failure status has been returned. If that is not the case, then the underlying library has a bug that needs to be addressed.
Addition:
Again NO! |
If Edit: As Homebridge UI makes nightly backups, I am making the assumption is that this functionality is available through an API call. |
README.md has not been updated with the latest options. Copilot gets an overall grade of D. |
This should be better documented. Not updating the Docker container is due to the fact that the process updating the container would be running inside the container itself, so it would end up killing itself halfway through the update. Edit: I think this should be clearly stated because at some point someone would reasonably ask for this functionality. |
|
Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
You're absolutely right. The 10-second delay was unnecessary and inappropriate since the npm update processes have already completed by the time we reach the restart logic. I've removed the arbitrary delay and the restart now happens immediately after the update processes finish successfully. The npm commands are properly awaited, so there are no race conditions to manage. Commit 8ec2afc fixes this issue. |
|
|
|
Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
I've implemented automatic backup creation before performing any automatic updates. The plugin now:
The implementation removes the need for manual backup procedures while maintaining safety through proper error handling and logging. Changes in commit 2922ce5. |
…r documentation Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
I've updated the README.md to include all missing configuration options (
I've expanded the Docker documentation to clearly explain the technical reason why Docker container updates aren't supported: the process performing the update would be running inside the container itself, which would result in the process killing itself halfway through the update, potentially corrupting the container. This explanation is now included in the README.md. Changes in commit c36ac06. |
This PR adds comprehensive automatic update functionality to the homebridge-plugin-update-check plugin, allowing users to automatically install updates for Homebridge, Homebridge UI, and plugins with configurable restart behavior, automatic backup creation, and customizable failure notifications.
Key Features
Automatic Update Configuration
Added four new boolean configuration options (all default to
false
for safety):autoUpdateHomebridge
: Automatically install Homebridge updates when availableautoUpdateHomebridgeUI
: Automatically install Homebridge Config UI updates when availableautoUpdatePlugins
: Automatically install plugin updates when availableallowDirectNpmUpdates
: Allow automatic updates using direct npm commands even when homebridge-config-ui-x is not availableAutomatic Restart Configuration
Added new configuration option:
autoRestartAfterUpdates
: Automatically restart Homebridge after successful automatic updates to apply changes (defaults tofalse
)Automatic Backup Creation
Added automatic backup functionality before performing any updates:
/api/backup/create
,/api/backups/create
,/api/backup
,/api/server/backup
)Configurable Failure Notification System
Added dedicated failure monitoring with user-selectable notification types:
failureSensorType
Configuration: Users can select the sensor type for failure notifications (motion, contact, occupancy, humidity, light, air quality, leak, smoke, carbon dioxide, carbon monoxide)Flexible Update Methods
The plugin now supports two update approaches:
allowDirectNpmUpdates
is enabledSmart Restart Logic
Example Configuration
Implementation Details
allowDirectNpmUpdates
is enabledautoRestartAfterUpdates
is enablednpm install -g
) to safely install updates with proper error handlingforceNcu
or when homebridge-config-ui-x is not configuredSafety Considerations
false
for maximum safetyThe implementation prioritizes safety and user control while providing maximum flexibility for different Homebridge configurations, now with fully customizable failure monitoring, notifications, and automatic backup creation that eliminates the need for manual backup procedures.
Fixes #93.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.