Store the switch state and commit changes to the controller only if there was an actual switch state change.