-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Light Switch Hotfixes v2 #42774
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
Light Switch Hotfixes v2 #42774
Conversation
…de is changed to sunset or the coords change
khmyznikov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Should fix: #42627 Issue: Suntimes not updating within the day if the mode changes to SunsetToSunrise Fix: Update suntimes in the service if the mode is changed to Sun mode. Other: small bug fixes (brackets, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the LightSwitch service to immediately recalculate sun times when the schedule mode changes to SunsetToSunrise or when coordinates change, improving responsiveness to user configuration updates.
- Fixed a logging typo where dark mode was incorrectly logged as "light mode"
- Added tracking variables for previous schedule mode and coordinates to detect changes
- Implemented immediate sun time recalculation when mode or coordinates change
- Added braces to conditional blocks for consistency
| prevMode = settings.scheduleMode; | ||
| prevLat = settings.latitude; | ||
| prevLon = settings.longitude; | ||
| } |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tracking variables (prevMode, prevLat, prevLon) are never updated when the mode is Off or when changing to FixedHours mode. If a user changes mode from SunsetToSunrise → Off → SunsetToSunrise with the same coordinates, the code will incorrectly detect this as 'modeChangedToSunset' and recalculate unnecessarily. Similarly, coordinate changes won't be tracked when not in SunsetToSunrise mode. Update prevMode unconditionally after the condition check, and consider tracking coordinates regardless of mode.
| prevMode = settings.scheduleMode; | |
| prevLat = settings.latitude; | |
| prevLon = settings.longitude; | |
| } | |
| } | |
| // Always update tracking variables after checking for changes | |
| prevMode = settings.scheduleMode; | |
| prevLat = settings.latitude; | |
| prevLon = settings.longitude; |
Should fix: microsoft#42627 Issue: Suntimes not updating within the day if the mode changes to SunsetToSunrise Fix: Update suntimes in the service if the mode is changed to Sun mode. Other: small bug fixes (brackets, etc)
Should fix: #42627
Issue: Suntimes not updating within the day if the mode changes to SunsetToSunrise
Fix: Update suntimes in the service if the mode is changed to Sun mode.
Other: small bug fixes (brackets, etc)