Skip to content

Conversation

@Jaylyn-Barbee
Copy link
Contributor

@Jaylyn-Barbee Jaylyn-Barbee commented Oct 22, 2025

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)

…de is changed to sunset or the coords change
@Jaylyn-Barbee Jaylyn-Barbee added Hot Fix Items we will product an out-of-band release for Product-LightSwitch labels Oct 22, 2025
Copy link
Contributor

@khmyznikov khmyznikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@khmyznikov khmyznikov merged commit 2c4aab9 into microsoft:main Oct 22, 2025
10 checks passed
khmyznikov pushed a commit that referenced this pull request Oct 22, 2025
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)
@yeelam-gordon yeelam-gordon requested a review from Copilot November 7, 2025 02:00
Copy link
Contributor

Copilot AI left a 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

Comment on lines +253 to +256
prevMode = settings.scheduleMode;
prevLat = settings.latitude;
prevLon = settings.longitude;
}
Copy link

Copilot AI Nov 7, 2025

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
mirmirmirr pushed a commit to mirmirmirr/PowerToys that referenced this pull request Nov 9, 2025
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)
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.96 milestone Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hot Fix Items we will product an out-of-band release for Product-LightSwitch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LightSwitch not switching to Light Mode

4 participants