Added state change detection for device checking script